On Tue, Nov 18, 2014 at 11:41:09PM +0100, Helmut Grohne wrote: > On Tue, Nov 18, 2014 at 09:25:44AM +0000, Simon McVittie wrote: > > There are (at least) three things that start services (i.e. init > > scripts, systemd units or Upstart jobs):
> > * invoke-rc.d, intended to be called from maintainer scripts > > * service, intended to be called by the sysadmin > > * the normal boot process > There is a fourth one that restarts/reloads services: logrotate > Please excuse a little excursion into the inhomogeneity of signalling > services from logrotate. I did a little bit of research and came up > with the following numbers (sid i386+all main): > -> 360 packages shipping logrotate files > -> 192 with scripts (e.g. reloading a daemon) > -> 64 using invoke-rc.d > -> 34 invoking /etc/init.d/something directly > -> 24 killing via pidifle > -> 13 using killall (I couldn't believe it at first) > -> 7 using start-stop-daemon (the policy has an example) > -> 6 using the service wrapper mentioned above > (some overlaps: > e.g. "[ -x /etc/init.d/foo ] && service foo reload") > From this little exercise, it seems that it is not well understood in > what way services should be signalled after log rotation. In particular, > it seems to me that service and invoke-rc.d should not be both valid. So > I ask: > Should logrotate snippets honour policy-rc.d (and use invoke-rc.d) or > should they ignore policy-rc.d (and likely use service)? Why? > It also seems that quite a few services use custom reload actions in > their init.d script (e.g. "reopen-logs", "rotate", "reconfig", > "reopenlog"). Is there a separate action for reopening logs for any init > system? The inconsistency reflects the fact that there is no standard way that gets this right under sysvinit. For instance, samba does 'service smbd reload'. Crucially, this uses *reload*, which is not a required command for init scripts but happens to be implemented for smbd; and is implemented sensibly for upstart and, I suspect, for systemd, though I haven't actually checked. Because 'reload' can be relied upon to work to provide a graceful reload, using 'service' works here; we *always* want to reload, without mediation by invoke-rc.d because that should really only control the policy for starting and stopping of services - not for whether you're allowed to reload a service that's currently running (possibly even running out of runlevel). However, if your init script didn't implement 'reload', it would *not* be appropriate to blindly call 'service foo force-reload' or 'service foo restart' in its place, since by policy, 'restart' will start the service if it's not already running. In that case, using 'invoke-rc.d' may be the lesser evil. > It also seems that using /etc/init.d/service with actions start or > restart is a bad idea when using the default init system. The following > packages do that however: <snip> Provided these packages use the lsb functions, calling /etc/init.d/service is safe under both upstart and systemd because the init script will be transparently redirected to the native service manager when needed. -- Steve Langasek Give me a lever long enough and a Free OS Debian Developer to set it on, and I can move the world. Ubuntu Developer http://www.debian.org/ slanga...@ubuntu.com vor...@debian.org
signature.asc
Description: Digital signature