Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 122786 - start-stop-daemon documentation
Summary: start-stop-daemon documentation
Status: RESOLVED FIXED
Alias: None
Product: [OLD] Docs on www.gentoo.org
Classification: Unclassified
Component: Other documents (show other bugs)
Hardware: All Other
: High normal (vote)
Assignee: nm (RETIRED)
URL: http://www.gentoo.org/doc/en/handbook...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-14 05:47 UTC by Roy Marples (RETIRED)
Modified: 2006-09-07 01:23 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
hb-working-rcscripts.xml.patch (hb-working-rcscripts.xml.patch,3.12 KB, patch)
2006-09-06 20:24 UTC, nm (RETIRED)
Details | Diff
hb-working-rcscripts.xml.patch + calling external scripts (hb-working-rcscripts.xml.patch,3.72 KB, patch)
2006-09-07 00:30 UTC, nm (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roy Marples (RETIRED) gentoo-dev 2006-02-14 05:47:17 UTC
The start-stop-demon example given should not include the --quiet option and is quite basic. Here is something with more meat.

Both --exec and --pidfile should be used in --start and --stop for system robustness. If the daemon does not create a pidfile then use --make-pidfile if possible (test if it works), otherwise don't use pidfiles.

Here are some examples

start() {
  start-stop-daemon --start --exec /path/to/daemon \
    --pidfile /path/to/pidfile
}

stop() {
  start-stop-daemon --stop --exec /path/to/daemon \
    --pidfile /path/to/pidfile
}

NOTE: Don't use the --quiet option unless the daemon is uncontrollably chatty. Use of it may hinder debugging the reason why the daemon did not start.

WARNING: Ensure that --exec actually calls a daemon and not just a shell script that launches daemon(s) and then exits - that is what the init script is supposed todo.
Comment 1 Roy Marples (RETIRED) gentoo-dev 2006-07-12 04:12:13 UTC
Might also be an idea to say something like this

If the daemon needs to write to local disks, then it should need localmount and if it puts anything in /var/run such as a pidfile then it should after bootmisc

depend() {
   need localmount
   after bootmisc
}
Comment 2 nm (RETIRED) gentoo-dev 2006-09-06 20:24:59 UTC
Created attachment 96227 [details, diff]
hb-working-rcscripts.xml.patch

Here's what is hopefully a nice patch as you requested. I took the liberty of rearranging things into a better flow (more readable and logical) as well as adding ebegin & eend to the stop() example.

UberLord, what do you think? Is this acceptable?
Comment 3 Roy Marples (RETIRED) gentoo-dev 2006-09-06 23:41:11 UTC
Looks good.

You may also want to note that if you're calling a script (bash, perl, python) that becomes a demon and changes it's name to "foo" then you may need to use --name foo in the s-s-d line too. See bug #143951 for why.
Comment 4 nm (RETIRED) gentoo-dev 2006-09-07 00:19:07 UTC
(In reply to comment #3)
> Looks good.
> 
> You may also want to note that if you're calling a script (bash, perl, python)
> that becomes a demon and changes it's name to "foo" then you may need to use
> --name foo in the s-s-d line too. See bug #143951 for why.
> 

I'm working on this, which I will attach in just a bit, but I'm not sure that this should be documented -- it seems a little out of place; maybe unnecessary even for "power" users?

After all, you did just mention "ensure that --exec actually calls a daemon and not just a shell script that launches daemon(s) and then exits" -- surely this is what calling a python script (for example) does, in which case, maybe it really should be in the user's bashrc, rather than using Gentoo's s-s-d framework. I don't see how you could avoid this improper bevahior in your script if you actually write a service that launches that script.
Comment 5 nm (RETIRED) gentoo-dev 2006-09-07 00:30:43 UTC
Created attachment 96255 [details, diff]
hb-working-rcscripts.xml.patch + calling external scripts
Comment 6 Roy Marples (RETIRED) gentoo-dev 2006-09-07 00:43:22 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > Looks good.
> > 
> > You may also want to note that if you're calling a script (bash, perl, python)
> > that becomes a demon and changes it's name to "foo" then you may need to use
> > --name foo in the s-s-d line too. See bug #143951 for why.
> > 
> 
> I'm working on this, which I will attach in just a bit, but I'm not sure that
> this should be documented -- it seems a little out of place; maybe unnecessary
> even for "power" users?
> 
> After all, you did just mention "ensure that --exec actually calls a daemon and
> not just a shell script that launches daemon(s) and then exits" -- surely this
> is what calling a python script (for example) does, in which case, maybe it
> really should be in the user's bashrc, rather than using Gentoo's s-s-d
> framework. I don't see how you could avoid this improper bevahior in your
> script if you actually write a service that launches that script.

Ah, but in this instance the script IS the daemon, so we're OK.
I was talking about scripts that are NOT daemons themselves.

BTW, your new patch looks good
Comment 7 nm (RETIRED) gentoo-dev 2006-09-07 01:23:50 UTC
Fixed in CVS. Thanks for taking the time to go over this, UberLord. :)