Compare commits
6 commits
8dc6021b7d
...
b894e95aea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b894e95aea | ||
|
|
14e914832e | ||
|
|
361dce90eb | ||
|
|
21585a1ae3 | ||
|
|
4321690105 | ||
|
|
dff0868d8a |
4 changed files with 77 additions and 8 deletions
5
d3d.rc
5
d3d.rc
|
|
@ -1,5 +1,6 @@
|
||||||
#! /usr/bin/env ./irena
|
#! /usr/bin/env ./irena
|
||||||
pid_file d3d/irena.pid
|
verbosity 2 2
|
||||||
|
pidfile d3d/irena.pid
|
||||||
path reset_gpio /run/gpio/Reset/value
|
path reset_gpio /run/gpio/Reset/value
|
||||||
path eint1_gpio /run/gpio/EINT1/value
|
path eint1_gpio /run/gpio/EINT1/value
|
||||||
uart /dev/ttyS1 gpio
|
uart /dev/ttyS1 gpio
|
||||||
|
|
|
||||||
26
etc/rc.local
Executable file
26
etc/rc.local
Executable file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/bash -vx
|
||||||
|
|
||||||
|
## call this script from /etc/rc.local
|
||||||
|
# chmod -v a+x /etc/rc.local
|
||||||
|
# echo $0 >> /etc/rc.local
|
||||||
|
|
||||||
|
D3D="$(dirname $0)"
|
||||||
|
IRENA=$D3D/d3d.rc
|
||||||
|
IMON=$D3D/imonitor.py
|
||||||
|
U=$(stat "$0" -c "%U")
|
||||||
|
|
||||||
|
## disable getty on $T
|
||||||
|
# sed -i 's/^2:/#2:/' /etc/inittab
|
||||||
|
|
||||||
|
T=/dev/tty2
|
||||||
|
|
||||||
|
if [ -x "$IRENA" ]
|
||||||
|
then
|
||||||
|
cd $D3D
|
||||||
|
sudo -inu $U screen -S IRENA -d -m $IRENA
|
||||||
|
[ -x "$IMON" ] && sudo -inu $U screen -S IRENA -X screen $IMON
|
||||||
|
chown $U $T
|
||||||
|
sudo -inu $U setsid <$T >$T 2>&1 screen -S IRENA -x &
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
27
etc/watchdog.conf
Normal file
27
etc/watchdog.conf
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
# ====================================================================
|
||||||
|
# Configuration for the watchdog daemon. For more information on the
|
||||||
|
# parameters in this file use the command 'man watchdog.conf'
|
||||||
|
# ====================================================================
|
||||||
|
|
||||||
|
watchdog-device = /dev/watchdog
|
||||||
|
watchdog-timeout = 60
|
||||||
|
|
||||||
|
log-dir = /var/log/watchdog
|
||||||
|
admin =
|
||||||
|
realtime = yes
|
||||||
|
priority = 1
|
||||||
|
|
||||||
|
# Verify that these file update regularly
|
||||||
|
|
||||||
|
# irena-status is written by irena.c.
|
||||||
|
file = /home/etd3d1/d3d/d3direna/d3d/irena-status
|
||||||
|
change = 600
|
||||||
|
|
||||||
|
# irena-live is written by the watch script, verifying
|
||||||
|
# that data acquisition runs properly
|
||||||
|
file = /home/etd3d1/d3d/d3direna/d3d/irena-live
|
||||||
|
change = 600
|
||||||
|
|
||||||
|
# Verify that the irena.c process is still running.
|
||||||
|
pidfile = /home/etd3d1/d3d/d3direna/d3d/irena.pid
|
||||||
|
|
||||||
27
irena.c
27
irena.c
|
|
@ -141,7 +141,7 @@ static const char tempfile_postfix[8] = "+";
|
||||||
const char *format_filename(struct file_format *ff, time_t t)
|
const char *format_filename(struct file_format *ff, time_t t)
|
||||||
{
|
{
|
||||||
if (!*ff->format)
|
if (!*ff->format)
|
||||||
return *ff->filename ? ff->filemame : 0;
|
return *ff->filename ? ff->filename : 0;
|
||||||
if (!t)
|
if (!t)
|
||||||
t = time(0);
|
t = time(0);
|
||||||
struct tm gm;
|
struct tm gm;
|
||||||
|
|
@ -207,6 +207,12 @@ void file_close(struct file_format *ff)
|
||||||
if (rename(ff->filename, fn))
|
if (rename(ff->filename, fn))
|
||||||
merror(ff->filename);
|
merror(ff->filename);
|
||||||
}
|
}
|
||||||
|
if (verbose(2))
|
||||||
|
fprintf(mout, "closed and renamed «%s» to «%s»\n", ff->filename, fn);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (verbose(2))
|
||||||
|
fprintf(mout, "closed file «%s»\n", ff->filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,22 +245,30 @@ void file_open(struct file_format *ff, time_t t)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ff->flags & FILE_STDIO) {
|
if (ff->flags & FILE_STDIO) {
|
||||||
ff->f = fopen(ff->filename, ff->flags&FILE_APPEND ? "a" : "w");
|
char *mode = ff->flags&FILE_APPEND ? "a" : "w";
|
||||||
if (ff->f)
|
ff->f = fopen(ff->filename, mode);
|
||||||
|
if (ff->f) {
|
||||||
|
if (verbose(2))
|
||||||
|
fprintf(mout, "fopen(%s, %s)\n",
|
||||||
|
ff->filename, mode);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mode_t f = O_CREAT|O_WRONLY|O_EXCL;
|
mode_t f = O_CREAT|O_WRONLY|O_EXCL;
|
||||||
if (ff->flags & FILE_APPEND)
|
if (ff->flags & FILE_APPEND)
|
||||||
f = O_CREAT|O_WRONLY|O_TRUNC;
|
f = O_CREAT|O_WRONLY|O_TRUNC;
|
||||||
ff->fd = open(ff->filename, f, 0664);
|
ff->fd = open(ff->filename, f, 0664);
|
||||||
if (ff->fd>=0)
|
if (ff->fd>=0) {
|
||||||
|
if (verbose(2))
|
||||||
|
fprintf(mout, "open(%s)\n", ff->filename);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
merror(ff->filename);
|
merror(ff->filename);
|
||||||
ff->flags |= FILE_ERROR;
|
ff->flags |= FILE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int file_cron(struct file_format *ff, time_t t, int delay)
|
int file_cron(struct file_format *ff, time_t t, int delay)
|
||||||
{
|
{
|
||||||
if (ff->rotate <= 0 || ff->flags & (FILE_STDOUT| FILE_STDERR))
|
if (ff->rotate <= 0 || ff->flags & (FILE_STDOUT| FILE_STDERR))
|
||||||
|
|
@ -352,6 +366,7 @@ int write_pidfile()
|
||||||
FILE *f = is_fwrite(&pid_file);
|
FILE *f = is_fwrite(&pid_file);
|
||||||
if (!f) return -1;
|
if (!f) return -1;
|
||||||
fprintf(f, "%d\n", getpid());
|
fprintf(f, "%d\n", getpid());
|
||||||
|
fflush(f);
|
||||||
file_close(&pid_file);
|
file_close(&pid_file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -3093,7 +3108,7 @@ int process_cmd(char *l)
|
||||||
return config_file(&status_file, na0, av);
|
return config_file(&status_file, na0, av);
|
||||||
|
|
||||||
if (!strcmp(av[0], "pidfile")) {
|
if (!strcmp(av[0], "pidfile")) {
|
||||||
if (!config_file(&pid_file, na0, av))
|
if (config_file(&pid_file, na0, av) >= 0)
|
||||||
write_pidfile();
|
write_pidfile();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue