FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Development

 
 
LinkBack Thread Tools
 
Old 07-06-2008, 12:13 AM
Russ Allbery
 
Default Bug#426877: Clarify what "sensible behaviour" is for init scripts

""Iņaki" Baz Castillo" <ibc@aliax.net> writes:

> Opssss, sorry, I meant that "lighttpd DOESN'T use LSB specs but Debian
> specs".
>
> You say that "it's not a sensible behaviour to fail when asked to start
> a service that is already running" but this is the default behaviour of
> Debian init scripts (dince --oknodo is optional and of course not always
> used).

Note that /etc/init.d/skeleton, on which many init scripts in Debian are
based, handles this case correctly without using --oknodo.

--
Russ Allbery (rra@debian.org) <http://www.eyrie.org/~eagle/>


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 07-06-2008, 11:48 AM
"Iņaki Baz Castillo"
 
Default Bug#426877: Clarify what "sensible behaviour" is for init scripts

> Note that /etc/init.d/skeleton, on which many init scripts in Debian are
> based, handles this case correctly without using --oknodo.

Are you sure? These are the "start" and "stop" sections of skeleton
file in a Debian Etch:

-------------
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec
$DAEMON --test > /dev/null
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --
$DAEMON_ARGS
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}

#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5
--pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5
--exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
-------------

This is not the LSB behaviour. Athe --oknodo is just present in the
second call to "start-stop-daemon" of the "stop" action (and no more),
and the text is very clear:

do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started

do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped



2008/7/6, Russ Allbery <rra@debian.org>:
> ""Iņaki" Baz Castillo" <ibc@aliax.net> writes:
>
>> Opssss, sorry, I meant that "lighttpd DOESN'T use LSB specs but Debian
>> specs".
>>
>> You say that "it's not a sensible behaviour to fail when asked to start
>> a service that is already running" but this is the default behaviour of
>> Debian init scripts (dince --oknodo is optional and of course not always
>> used).
>
> Note that /etc/init.d/skeleton, on which many init scripts in Debian are
> based, handles this case correctly without using --oknodo.
>
> --
> Russ Allbery (rra@debian.org) <http://www.eyrie.org/~eagle/>
>


--
Iņaki Baz Castillo
<ibc@aliax.net>
 
Old 07-06-2008, 01:57 PM
"Iņaki Baz Castillo"
 
Default Bug#426877: Clarify what "sensible behaviour" is for init scripts

2008/7/6 Raphael Hertzog <hertzog@debian.org>:

> No those are functions... the main code runs without "set -e" and thus doesn't
> fail on the error and the return value of the function is checked:
>
> do_start
> case "$?" in
> 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
> 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
> esac
>
>
> If do_start returns 0 or 1, the whole script returns "0" (hence success).

Thanks for pointing that, you are right. Anyway I consider it a bit
complex and the fact is that various Debian init scripts return 1 in
the above case.

Thanks for all.


--
Iņaki Baz Castillo
<ibc@aliax.net>
 

Thread Tools




All times are GMT. The time now is 12:26 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright Š2007 - 2008, www.linux-archive.org