Compare commits
6 commits
8dc6021b7d
...
b894e95aea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b894e95aea | ||
|
|
14e914832e | ||
|
|
361dce90eb | ||
|
|
21585a1ae3 | ||
|
|
4321690105 | ||
|
|
dff0868d8a |
4 changed files with 77 additions and 8 deletions
3
d3d.rc
3
d3d.rc
|
|
@ -1,5 +1,6 @@
|
|||
#! /usr/bin/env ./irena
|
||||
pid_file d3d/irena.pid
|
||||
verbosity 2 2
|
||||
pidfile d3d/irena.pid
|
||||
path reset_gpio /run/gpio/Reset/value
|
||||
path eint1_gpio /run/gpio/EINT1/value
|
||||
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
|
||||
|
||||
25
irena.c
25
irena.c
|
|
@ -141,7 +141,7 @@ static const char tempfile_postfix[8] = "+";
|
|||
const char *format_filename(struct file_format *ff, time_t t)
|
||||
{
|
||||
if (!*ff->format)
|
||||
return *ff->filename ? ff->filemame : 0;
|
||||
return *ff->filename ? ff->filename : 0;
|
||||
if (!t)
|
||||
t = time(0);
|
||||
struct tm gm;
|
||||
|
|
@ -207,6 +207,12 @@ void file_close(struct file_format *ff)
|
|||
if (rename(ff->filename, fn))
|
||||
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,18 +245,26 @@ void file_open(struct file_format *ff, time_t t)
|
|||
return;
|
||||
}
|
||||
if (ff->flags & FILE_STDIO) {
|
||||
ff->f = fopen(ff->filename, ff->flags&FILE_APPEND ? "a" : "w");
|
||||
if (ff->f)
|
||||
char *mode = ff->flags&FILE_APPEND ? "a" : "w";
|
||||
ff->f = fopen(ff->filename, mode);
|
||||
if (ff->f) {
|
||||
if (verbose(2))
|
||||
fprintf(mout, "fopen(%s, %s)\n",
|
||||
ff->filename, mode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mode_t f = O_CREAT|O_WRONLY|O_EXCL;
|
||||
if (ff->flags & FILE_APPEND)
|
||||
f = O_CREAT|O_WRONLY|O_TRUNC;
|
||||
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;
|
||||
}
|
||||
}
|
||||
merror(ff->filename);
|
||||
ff->flags |= FILE_ERROR;
|
||||
}
|
||||
|
|
@ -352,6 +366,7 @@ int write_pidfile()
|
|||
FILE *f = is_fwrite(&pid_file);
|
||||
if (!f) return -1;
|
||||
fprintf(f, "%d\n", getpid());
|
||||
fflush(f);
|
||||
file_close(&pid_file);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -3093,7 +3108,7 @@ int process_cmd(char *l)
|
|||
return config_file(&status_file, na0, av);
|
||||
|
||||
if (!strcmp(av[0], "pidfile")) {
|
||||
if (!config_file(&pid_file, na0, av))
|
||||
if (config_file(&pid_file, na0, av) >= 0)
|
||||
write_pidfile();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue