[Comm] Использование start-stop-daemon
Eugene Prokopiev
=?iso-8859-1?q?prokopiev_=CE=C1_stc=2Edonpac=2Eru?=
Пн Ноя 6 19:50:29 MSK 2006
> Рекомендую использовать функции start_daemon/stop_daemon.
> См. тж.
> http://lists.altlinux.org/pipermail/devel/2006-November/038198.html
Спасибо. Сейчас имею:
# cat /usr/bin/devman
#!/bin/sh
sleep 1000000
# cat /etc/init.d/devman
#!/bin/sh
#
# /etc/init.d/devman
#
# Startup script for devman
#
# chkconfig: - 85 15
# description: Device Manager
# processname: devman
#
WITHOUT_RC_COMPAT=1
# Source function library.
. /etc/init.d/functions
PIDFILE=/var/run/devman.pid
LOCKFILE=/var/lock/subsys/devman
USER=devman
RETVAL=0
start()
{
start_daemon --lockfile "$LOCKFILE" --make-pidfile --pidfile
"$PIDFILE" --set-user "$USER" -- devman
RETVAL=$?
return $RETVAL
}
stop()
{
stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE"
--expect-user root --displayname devman su
RETVAL=$?
return $RETVAL
}
restart()
{
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condstop)
if [ -e "$LOCKFILE" ]; then
stop
fi
;;
condrestart)
if [ -e "$LOCKFILE" ]; then
restart
fi
;;
condreload)
if [ -e "$LOCKFILE" ]; then
reload
fi
;;
status)
status --pidfile "$PIDFILE" --expect-user root
--displayname devman su
RETVAL=$?
;;
*)
msg_usage "${0##*/}
{start|stop|reload|restart|condstop|condrestart|condreload|status}"
RETVAL=1
esac
exit $RETVAL
Работает это так:
[root на devman ~]# ps aux | grep devman
root 9651 0.0 0.4 1584 468 pts/0 S+ 22:47 0:00 grep devman
[root на devman ~]# service devman start
Starting devman service:
[ DONE ]
[root на devman ~]# ps aux | grep devman
root 9662 1.5 1.0 2000 964 ? Ss 22:47 0:00 /bin/su
-s /bin/sh -l devman -c /usr/bin/devman
devman 9664 1.0 0.9 2064 852 ? S 22:47 0:00 /bin/sh
/usr/bin/devman
devman 9678 0.0 0.3 1408 372 ? S 22:47 0:00 sleep
1000000
root 9680 0.0 0.4 1580 464 pts/0 S+ 22:47 0:00 grep devman
[root на devman ~]# service devman stop
Stopping devman service:
[ DONE ]
[root на devman ~]# ps aux | grep devman
devman 9678 0.0 0.3 1408 372 ? S 22:47 0:00 sleep
1000000
root 9706 0.0 0.4 1584 468 pts/0 S+ 22:47 0:00 grep devman
Почему процесс sleep не останавливается?
--
С уважением, Прокопьев Евгений
Подробная информация о списке рассылки community