Commit 51c4b487 authored by Yargo ASUS2's avatar Yargo ASUS2

ambros: handle still running daemon

constants.sh: if available, use ramdisk for temp files
parent d7c2714a
......@@ -41,6 +41,9 @@ daemons=$TMPDIR/daemons$$.tmp
# arg1=action, arg2=channel, arg3=type, arg4=pid
# (arg4 only if action other than start)
dodaemon () {
if test "$1" = "none"
then return 0
fi
if test "$1" = "start"
then
$SCRIPTDIR/$3 $2 &
......@@ -176,8 +179,17 @@ do
then
if ps|grep "^ *$pid .*$type" >/dev/null 2>&1
then action=log
else action=start
logit $logf daemon "$type for $ch died"
else
daemstat=`configread $STATUSDIR/$type-$ch STATUS`
if test $daemstat -eq FAIL
then
logit $logf daemon "$type for $ch failed permanently:"
sed -e 's/^/### /' $STATUSDIR/$type-$ch >>$logf
action=none
else
logit $logf daemon "$type for $ch died, restarting"
action=start
fi
fi
dodaemon $action $ch $type $pid
fi
......
......@@ -21,14 +21,19 @@ EXTRACTORFILE=extractor.dat
if test ! -d "$TMPDIR" -o ! -w "$TMPDIR" -o ! -x "$TMPDIR" -o ! -r "$TMPDIR"
then
# if possible, use ramdisk (on Linux)
if test -d /dev/shm
then TMPDIR=/dev/shm/ambros
else TMPDIR=/tmp/ambros
if test -d /run/shm
then TMPDIR=/run/shm
else TMPDIR=/tmp
fi
TMPDIR=$TMPDIR/ambros
mkdir -p $TMPDIR || { echo cannot create tempdir $TMPDIR ; exit 4 ; }
fi
mkdir -p $TMPDIR || { echo cannot create tempdir $TMPDIR ; exit 4 ; }
# could be part of temp dir, but may be independent (long-lasting)
# used by daemons for status reports
STATUSDIR=$TMPDIR/status
mkdir -p $STATUSDIR || { echo cannot create statusdir $STATUSDIR ; exit 4 ; }
# could be part of temp dir, but may be independent (longer lasting)
LOGDIR=/tmp/ambros/log
mkdir -p $LOGDIR || { echo cannot create logdir $LOGDIR ; exit 4 ; }
# logfile generator, argument is log name specification
......@@ -66,9 +71,11 @@ MININDEX=100
MAXINDEX=99999
# signal to terminate daemons (argument for kill)
DAEMONTERMINATE=HUP
SIGDAEMONTERMINATE=HUP
# signal to make daemons restart initialization
SIGDAEMONRESTART=INT
# signal to make daemons re-read files for urgent messages
DAEMONXXX=INT
SIGDAEMONXXX=INT
# function to read config value by name
# arguments: configfile name [separators]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment