[fpc-pascal] Stopping daemon in linux

Joost van der Sluis joost at cnoc.nl
Mon Nov 9 14:33:43 CET 2009


On Mon, 2009-11-09 at 14:14 +0100, Michael Van Canneyt wrote:
> 
> On Mon, 9 Nov 2009, Joost van der Sluis wrote:
> >
> > I don't know how I did it exactly, but I ahve this working properly in a
> > production system. (Even created my own SysV init script for it. It
> > should be generally usable for all fpc-daemon applications)
> 
> That's good news: I had it on my todo list to let the 'Install' mode generate
> this script in the appropriate directory. If I can use your script as a
> start, then I can implement that.

See below. Description and daemonname/filenames should be adapted,
offcourse.

#!/bin/bash
#
# startupmaildaemon     startup script for  the IA-MailDaemon
#
# chkconfig: - 2345 20 80
# description: MailDaemon wordt gebruikt om mailtjes die geagendeerd zijn om  \
#              te versturen in de IA ook daadwerkelijk te versturen
# processname: maildaemon
# pidfile: /var/run/maildaemon.pid

. /etc/rc.d/init.d/functions

prog=MailDaemon
maildaemon=${MAILDAEMON-/opt/maildaemon/maildaemon}
pidfile=${PIDFILE-/var/run/maildaemon.pid}
lockfile=${LOCKFILE-/var/lock/subsys/maildaemon}
runasuser=${RUNUSER-apache}
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        sudo -b -u $runasuser $maildaemon -b -r
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}


stop() {
        echo -n $"Stopping $prog: "
        killproc -d 10 $maildaemon
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}


case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        ;;
  *)
         echo "Usage: $0 {start|stop|restart}"
         exit 1
esac
exit 0





More information about the fpc-pascal mailing list