Gentoo Archives: gentoo-dev

From: Francesco R <vivo@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] init script guidelines
Date: Tue, 19 Jul 2005 22:19:04
Message-Id: 42DD7BDB.5000600@gentoo.org
In Reply to: Re: [gentoo-dev] init script guidelines by Roy Marples
1 Roy Marples wrote:
2
3 >On Tue, 2005-07-19 at 12:42 -0400, Eric Brown wrote:
4 >
5 >
6 >
7 >
8 >>The real problem is not that the daemons don't return errors, but that our init
9 >>scripts do not make reasonable attempts to verify service startup. If a Gentoo
10 >>init script claims that a service started, it should make an effort to check
11 >>that the processes are actually running shortly after the script is run, even if
12 >>start-stop-daemon says the parent process initialized. Relying on the return
13 >>value of start-stop-daemon is simply insufficient for some services.
14 >>
15 >>
16 >
17 >I agree.
18 >
19 >Infact, rc-services.sh (/lib/rcscripts/sh) has been totally re-written
20 >for the baselayout-1.12.x branch. It now intercepts calls to
21 >start-stop-daemon and checks if the daemon is still active after a
22 >default time of 0.1 (adjustable) seconds. If not, the we assume the
23 >daemon failed. This solves many existing bugs :)
24 >
25 >Also, we kill any rogue processes and other such checks when a stop call
26 >to start-stop-daemon is made - which is handy for when asterisk fails to
27 >start and leaves mpg123 processes lying around :)
28 >
29 >Check it out when baselayout-1.12.0pre1 hits portage!
30 >
31 >Caveat: - some init scripts abuse start-stop-daemon. One example are all
32 >courier scripts which pass the env program as a daemon. This is easily
33 >worked around, but we fail badly if env then calls a shell script which
34 >in turn launches a daemon. Of all the server stuff I run, only couier
35 >has this issue - but there may be other programs too. Basically
36 >start-stop-daemon should only call daemons!
37 >
38 >http://bugs.gentoo.org/show_bug.cgi?id=98745
39 >
40 >Roy
41 >
42 >
43
44 what about to define two additional functions
45
46 check_startup() and check_shutdown()
47
48 intended to be filled from package mantainer.
49 The rc scripts can call these one to check if a service is
50 started/stopped or not.
51 If not it wait and retry untill a timeout is reached.
52
53 This open the road also to centralized policies of waits between check
54 like :
55 (1,1,1,1,1,1) (1,2,3,4,5,6) (1,2,4,8,16,32) and other nice stuff.
56
57 Francesco
58 --
59 gentoo-dev@g.o mailing list