Compare commits

..

No commits in common. "b894e95aea3a71f79677672858d181f3f564c8c2" and "8dc6021b7d2472e0156918098cf244ac91985fdb" have entirely different histories.

4 changed files with 8 additions and 77 deletions

5
d3d.rc
View file

@ -1,6 +1,5 @@
#! /usr/bin/env ./irena
verbosity 2 2
pidfile d3d/irena.pid
#! /usr/bin/env ./irena
pid_file d3d/irena.pid
path reset_gpio /run/gpio/Reset/value
path eint1_gpio /run/gpio/EINT1/value
uart /dev/ttyS1 gpio

View file

@ -1,26 +0,0 @@
#!/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

View file

@ -1,27 +0,0 @@
# ====================================================================
# 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
View file

@ -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->filename : 0;
return *ff->filename ? ff->filemame : 0;
if (!t)
t = time(0);
struct tm gm;
@ -207,12 +207,6 @@ 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);
}
}
@ -245,30 +239,22 @@ void file_open(struct file_format *ff, time_t t)
return;
}
if (ff->flags & FILE_STDIO) {
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);
ff->f = fopen(ff->filename, ff->flags&FILE_APPEND ? "a" : "w");
if (ff->f)
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 (verbose(2))
fprintf(mout, "open(%s)\n", ff->filename);
if (ff->fd>=0)
return;
}
}
merror(ff->filename);
ff->flags |= FILE_ERROR;
}
int file_cron(struct file_format *ff, time_t t, int delay)
{
if (ff->rotate <= 0 || ff->flags & (FILE_STDOUT| FILE_STDERR))
@ -366,7 +352,6 @@ 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;
}
@ -3108,7 +3093,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) >= 0)
if (!config_file(&pid_file, na0, av))
write_pidfile();
return 0;
}