Compare commits
No commits in common. "b894e95aea3a71f79677672858d181f3f564c8c2" and "8dc6021b7d2472e0156918098cf244ac91985fdb" have entirely different histories.
b894e95aea
...
8dc6021b7d
4 changed files with 8 additions and 77 deletions
5
d3d.rc
5
d3d.rc
|
|
@ -1,6 +1,5 @@
|
||||||
#! /usr/bin/env ./irena
|
#! /usr/bin/env ./irena
|
||||||
verbosity 2 2
|
pid_file d3d/irena.pid
|
||||||
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
26
etc/rc.local
|
|
@ -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
|
|
||||||
|
|
@ -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
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->filename : 0;
|
return *ff->filename ? ff->filemame : 0;
|
||||||
if (!t)
|
if (!t)
|
||||||
t = time(0);
|
t = time(0);
|
||||||
struct tm gm;
|
struct tm gm;
|
||||||
|
|
@ -207,12 +207,6 @@ 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,30 +239,22 @@ void file_open(struct file_format *ff, time_t t)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ff->flags & FILE_STDIO) {
|
if (ff->flags & FILE_STDIO) {
|
||||||
char *mode = ff->flags&FILE_APPEND ? "a" : "w";
|
ff->f = fopen(ff->filename, ff->flags&FILE_APPEND ? "a" : "w");
|
||||||
ff->f = fopen(ff->filename, mode);
|
if (ff->f)
|
||||||
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))
|
||||||
|
|
@ -366,7 +352,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
@ -3108,7 +3093,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) >= 0)
|
if (!config_file(&pid_file, na0, av))
|
||||||
write_pidfile();
|
write_pidfile();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue