From: Eugene Prokopiev <prokopiev@stc.donpac.ru>
To: ALT Linux Community <community@altlinux.ru>
Subject: [Comm] Использование start-stop-daemon
Date: Mon, 06 Nov 2006 13:56:57 +0300
Message-ID: <454F14F9.7090902@stc.donpac.ru> (raw)
Здравствуйте!
Имеется тупая программа, которая не умеет создавать PID-файл, не умеет
форкаться и освобождать терминал, однако ее требуется запустить как
сервис средствами start-stop-daemon (т.к. других для этих целей, как я
понял, у нас нет).
Пример такой программы:
# cat /usr/bin/myservice
#!/bin/sh
sleep 1000000
Стартовый скрипт:
# cat /etc/init.d/myservice
#!/bin/sh
#
# chkconfig: 2345 80 30
# description: myservice daemon
# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1
# Source function library.
. /etc/init.d/functions
PIDFILE=/var/run/myservice.pid
RETVAL=0
start()
{
action "Starting myservice service: " start-stop-daemon --quiet --start
-b -m --pidfile $PIDFILE --exec /usr/bin/myservice
RETVAL=$?
return $RETVAL
}
stop()
{
action "Stopping myservice service: " start-stop-daemon --stop --quiet
--pidfile $PIDFILE myservice
RETVAL=$?
return $RETVAL
}
restart()
{
stop
sleep 1
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
;;
status)
status --pidfile "$PIDFILE" --expect-user root -- myservice
RETVAL=$?
;;
*)
echo "Usage: ${0##*/}
{start|stop|reload|restart|condstop|condrestart|status}"
RETVAL=1
esac
exit $RETVAL
Ведет он себя безобразно:
[root@mydomain root]# ps aux | grep myservice
root 5782 0.0 0.0 1372 440 pts/1 S 13:46 0:00 grep
myservice
[root@mydomain root]# service myservice status
myservice is stopped
[root@mydomain root]# service myservice start
Starting myservice service:
[ DONE ]
[root@mydomain root]# ps aux | grep myservice
root 5797 0.2 0.1 1604 812 ? S 13:47 0:00 /bin/sh
/usr/bin/myservice
[root@mydomain root]# service myservice status
myservice is dead, but stale PID file exists
[root@mydomain root]# cat /var/run/myservice.pid
5797
[root@mydomain root]# service myservice stop
Stopping myservice service:
[ DONE ]
[root@mydomain root]# ps aux | grep myservice
[root@mydomain root]# cat /var/run/myservice.pid
5797
Т.е. стартует, но статус уже показать не может, вроде останавливает, но
PID-файл не удаляет. Что я сделал неправильно?
Да, раскопки с помощью /bin/bash -x показывают, что:
# start-stop-daemon --stop --test --exec /usr/bin/myservice
--user-fallback-to-name --pidfile /var/run/myservice.pid --user root
No /usr/bin/myservice found running; none killed.
Почему, если:
[root@mydomain root]# ps aux | grep myservice
root 5845 0.0 0.1 1604 812 ? S 13:52 0:00 /bin/sh
/usr/bin/myservice
[root@mydomain root]# cat /var/run/myservice.pid
5845
?
происходит все на ALM 2.4
--
С уважением, Прокопьев Евгений
next reply other threads:[~2006-11-06 10:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-06 10:56 Eugene Prokopiev [this message]
2006-11-06 11:24 ` Eugene Prokopiev
2006-11-06 13:41 ` Eugene Prokopiev
2006-11-06 15:00 ` Dmitry V. Levin
2006-11-06 16:50 ` Eugene Prokopiev
2006-11-06 20:17 ` Eugene Prokopiev
2006-11-06 20:54 ` Dmitry V. Levin
2006-11-06 21:10 ` Eugene Prokopiev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=454F14F9.7090902@stc.donpac.ru \
--to=prokopiev@stc.donpac.ru \
--cc=community@altlinux.ru \
--cc=community@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux Community general discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
public-inbox-index community
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.community
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git