ALT Linux Community general discussions
 help / color / mirror / Atom feed
* [Comm] Использование start-stop-daemon
@ 2006-11-06 10:56 Eugene Prokopiev
  2006-11-06 11:24 ` Eugene Prokopiev
  0 siblings, 1 reply; 8+ messages in thread
From: Eugene Prokopiev @ 2006-11-06 10:56 UTC (permalink / raw)
  To: ALT Linux Community

Здравствуйте!

Имеется тупая программа, которая не умеет создавать 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

-- 
С уважением, Прокопьев Евгений


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-11-06 21:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-06 10:56 [Comm] Использование start-stop-daemon Eugene Prokopiev
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

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