Ticket #160 (closed enhancement: fixed)
Opened 17 months ago
Last modified 16 months ago
start-stop-daemon can't wait for pidfile to be created
Reported by: | ohnobinki@ohnopublishing.net | Owned by: | roy |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | rc | Version: | 0.4 |
Keywords: | Cc: |
Description
I am trying to get my initscripts to work with spamassassin's spamd. Spamd writes a pidfile, but it takes over 4 seconds on my machine. I want start-stop-daemon to wait for this file, but can't get it to wait long enough.
If I set SSD_STARTWAIT=5000 or an extreme, start-stop-daemon waits less than a second for the following commands:
(commands removed)
I can verify that the pidfile exists if I wait 4 seconds after running those commands:
$ cat /var/run/spamd.pid
19155
spamd is a perl daemonized application. As it appears at http://cpansearch.perl.org/src/BBB/Net-Server-0.87/lib/Net/Server/Daemonize.pm (search for sub daemonize), the parent process forks a child to implement backgrounding. Then the child writes the pid. This prevents (I think) the --name spamd option from working, because start-stop-daemon will see the parent exiting and say that spamd died. In fact, this is the reason I wanted to try to get start-stop-daemon to wait for the pidfile.
Thankfully, I can avoid telling spamd to daemonize and use start-stop-daemon's --background option. But I think that there must be a better way of handling processes whose children create pidfiles. Maybe start-stop-daemon can be told to wait for a child process to be created and monitor that process rather than the parent which exit()s?
Change History
comment:1 Changed 17 months ago by roy
comment:2 Changed 17 months ago by ohnobinki@ohnopublishing.net
- Type changed from defect to enhancement
- Summary changed from start-stop-daemon can't wait long enough to start-stop-daemon can't wait for pidfile to be created
OK. I see that I misinterpreted the SSD_STARTWAIT environment variable's meaning. I suppose that this is a feature request to allow start-stop-daemon to wait for a process to create a pidfile.
comment:3 Changed 17 months ago by ohnobinki@ohnopublishing.net
Akismet still rejects my file upload. The spamd script I'd expect to work is http://ohnopublishing.net/~ohnobinki/anindex/spamd.custom. However, it fails with the following:
spamd |* Starting spamd...
spamd |* start-stop-daemon: did not create a valid pid in `/var/run/spamd.pid'
spamd |* Failed to start spamd [ !! ] |
spamd |* ERROR: spamd failed to start
It doesn't wait at all, etc. I am assuming that the patch suggested at http://bugs.gentoo.org/show_bug.cgi?id=243474#c7 works. However, my local solution is to have spamd not daemonize: http://ohnopublishing.net/~ohnobinki/anindex/spamd.works . I do this by changing removing the -d argument for the spamd command.
Could you attach the init script you are using for spamd?
I'm pretty sure the current Gentoo one works.
I'm sorry I didn't reply to your email btw ..... family crisis.