on your site http://apathy.guiltyparty.org/u/doc/mathopd/ i found the following:
if you use logrotate to manage /var/log, create a file called "mathopd" in /etc/logrotate.d/ and insert this:
/var/log/mathopd/log.* {
weekly
missingok
rotate 7
compress
create 640 daemon daemon
sharedscripts
postrotate
killall mathopd
sleep 5
/usr/local/sbin/mathopd < /etc/mathopd.conf
endscript
}
which kills mathopd. that's bad housekeeping and unnessacary.
see the attached file (an init-script) i wrote.
option 'force-nextlog' reopens the log, which is
given by
Log /var/mathopd/log/%Y-%m-%d
in mathopd.conf.at 00:00:00 daily cron executes the script
/etc/init.d/mathopd force-nextlog
so i get a daily log without any extra program.
it was originally written for suse linux and it needs some customizing but can do a great job. you can put it on your web-page if you'd like to.
#!/bin/sh # init.d script for mathopd. Set the variables below to something fitting.. # This is only an example script. #############
# The name of the executeable.
#
mathopdexec=mathopd
# The server directory where the executable is located.
#
mathopdhome=/usr/local/sbin/
# Set this to something unique to be able to stop, reload and restart
# with this init script. It will override the setting in the config
# interface. '0' is typically replaced with the uid.
#
pidfile=/var/mathopd/pid
# Set these to kill all processes owned by wwwuser on stop. Useful to
# reap CGI scripts.
#
# killallwww=yes
# wwwuser=www
umask 022
# If you want to start with another configuration directory:
#
# configdir=dirname
# Insert the name of the Configuration-File here
#
configfile=mathopd.conf
### You should not _have_ to change anything below here...
case $1 in
'start')
echo "Starting mathopd from $mathopdhome..."
if [ -z "$pidfile" ]; then
echo "Warning: No pid file set - cannot stop or reload."
elif [ -f "$pidfile" ]; then
read pid < $pidfile
if kill -0 $pid ; then
echo "mathopd is already running."
exit 0
fi
rm -f $pidfile
if [ -f "$pidfile" ]; then
echo Cannot remove pid file $pidfile
exit 1
fi
fi
if [ -x "$mathopdhome/$mathopdexec" ]; then
cd $mathopdhome
./$mathopdexec < $configfile 2>/dev/null
echo "Done."
else
echo "I cannot find the mathopd dir '('$mathopdhome')'"
fi
;;
'restart')
if [ -z "$pidfile" ] ; then
echo "No pid file set."
exit 1
fi
echo Restarting mathopd...
if [ -f "$pidfile" ] ; then
read pid < $pidfile
kill -INT $pid || kill 2 $pid
rm "$pidfile"
echo "Stopping mathopd..."
else
echo "mathopd doesn't seem to be running."
fi
echo Starting a new mathopd in $mathopdhome...
if [ -x "$mathopdhome/$mathopdexec" ]; then
cd $mathopdhome
./$mathopdexec < $configfile 2>/dev/null
else
echo "I cannot find the mathopd dir '('$mathopdhome')'"
fi
echo "Done."
;;
'stop')
if [ -z "$pidfile" ] ; then
echo "No pid file set."
exit 1
fi
echo "Stopping mathopd..."
if [ -f $pidfile ] ; then
if kill `cat $pidfile` ; then
echo mathopd stopped.
fi
rm $pidfile
else
echo "mathopd doesn't seem to be running."
fi
# Get all the CGI scripts... :-)
if [ x$killallwww = xyes ] ; then
echo Killing all programs running as the $wwwuser user.
su $wwwuser -c "kill -9 -1"
fi
;;
'force-nextlog')
# send HUP (=1)
/sbin/killproc -1 "$mathopdhome/$mathopdexec"
echo "logs reopened."
;;
'kill-connections')
# send USR1 (=10)
/sbin/killproc -10 "$mathopdhome/$mathopdexec"
echo "all connections killed."
;;
'safe-stop')
# send USR2 (=12)
/sbin/killproc -12 "$mathopdhome/$mathopdexec"
rm $pidfile
echo "waiting for connections to end and shutting down."
;;
'reap-children')
# send CHLD (=17)
/sbin/killproc -17 "$mathopdhome/$mathopdexec"
echo "reaped children."
;;
'switch-debug')
# send QUIT (=3)
/sbin/killproc -3 "$mathopdhome/$mathopdexec"
echo -n "debugging mode switched "
echo -n `tail -n 1 /var/mathopd/errorlog | cut -d " " -f 10`
echo "."
;;
'debug')
# send QUIT (=3)
/sbin/killproc -3 "$mathopdhome/$mathopdexec"
echo -n "debugging mode switched "
echo -n `tail -n 1 /var/mathopd/errorlog | cut -d " " -f 10`
echo "."
;;
'safe-restart')
# send USR2 (=12)
/sbin/killproc -12 "$mathopdhome/$mathopdexec"
rm $pidfile
echo "waiting for connections to end and shutting down."
if [ -x "$mathopdhome/$mathopdexec" ]; then
cd $mathopdhome
./$mathopdexec < $configfile 2>/dev/null
echo "now starting new instance with new configuration."
else
echo "I cannot find the mathopd dir '('$mathopdhome')'"
fi
;;
*)
echo "Syntax: $0
[start|stop|safe-stop|restart|safe-restart|force-nextlog|kill-connections|switch-debug]"
;;
esac
exit 0
