Hi all,
I need to start this Perl program as a service/daemon. Unfortunately, I'm not a "rc script" specialist. I have here the start/stop script on Gentoo, but how do I do this in FreeBSD?
Thanks for any help here,
parcival
I need to start this Perl program as a service/daemon. Unfortunately, I'm not a "rc script" specialist. I have here the start/stop script on Gentoo, but how do I do this in FreeBSD?
Code:
#!/sbin/runscript
NAME="zbxlog"
PIDFILE="/var/run/$NAME.pid"
PERL="/usr/bin/perl"
ZBXLOG="/bin/zbxlog.pl"
depend() {
need net
}
start() {
ebegin "Stating syslog collector for Zabbix"
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $PERL $ZBXLOG --test > /dev/null || return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --background --make-pidfile --exec $PERL $ZBXLOG || return 2
#or use
# start-stop-daemon --start --background --exec $PERL $ZBXLOG --pidfile $PIDFILE
eend
}
stop() {
ebegin "Stopping zbxlog"
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $PERL $ZBXLOG
[ "$?" = 2 ] && return 2
rm -f $PIDFILE
return "$RETVAL"
#or use
# start-stop-daemon --stop --exec $PERL $ZBXLOG --pidfile $PIDFILE
eend
}
Thanks for any help here,
parcival