Service supervision for forking daemons
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
upstart |
Fix Released
|
Wishlist
|
Unassigned |
Bug Description
Hi!
First of all, excuse my bad english, but i'll try my best :)
I'm writing for a german paper for school, that should show the main differences between sysvinit and upstart. Also I wrote a really simple daemon, that sleeps at the most of the time and write some messages into the syslog. You can see the sourcecode of it here -> http://
Now i copied it to /usr/bin and wrote a upstartjob for it:
cat /etc/event.
exec /usr/bin/bspdaemon
This should be enough, right?
Now I want to start it:
sudo start bspdcontrol
Password:
bspdcontrol (start) waiting
bspdcontrol (start) starting
bspdcontrol (start) pre-start
bspdcontrol (start) spawned, process 8457
bspdcontrol (start) post-start, (main) process 8457
bspdcontrol (start) running, process 8457
bspdcontrol (stop) running
bspdcontrol (stop) stopping
bspdcontrol (stop) killed
bspdcontrol (stop) post-stop
bspdcontrol (stop) waiting
start: bspdcontrol main process terminated with status 1
and
sudo status bspdcontrol
bspdcontrol (stop) waiting
is the output... BUT
pgrep bspdaemon
8458
show me this... Okay, so I thought the fork() command would be the reason, so I tried this source ->
http://
lewurm@
bspdcontrol (start) waiting
bspdcontrol (start) starting
bspdcontrol (start) pre-start
bspdcontrol (start) spawned, process 8657
bspdcontrol (start) post-start, (main) process 8657
bspdcontrol (start) running, process 8657
<CTRL+C>
but it never comes to an end, and I have to interrupt it with CTRL+C (I know I have to wait longer than 10 seconds).
But when I type
sudo status bspdcontrol
bspdcontrol (start) running, process 8657
it returns the correct output.
sudo stop bspdcontrol
bspdcontrol (stop) running, process 8657
bspdcontrol (stop) pre-stop, (main) process 8657
bspdcontrol (stop) stopping, process 8657
bspdcontrol (stop) killed, process 8657
bspdcontrol (stop) post-stop
bspdcontrol (stop) waiting
is also no problem.
So what's wrong with it?
May it isn't a bug, and I'm only to dumb to configure it in the right way... :/ When it is this case, please excuse me! :(
greeting,
Bernhard Urban
dpkg -l | grep upstart
ii upstart 0.3.8-1 event-based init daemon
ii upstart-compat-sysv 0.3.8-1 compatibility for System-V-like init
ii upstart-logd 0.3.8-1 boot logging daemon
Changed in upstart: | |
status: | Confirmed → Triaged |
Changed in upstart: | |
status: | Fix Committed → Fix Released |
Hello,
I'll try and answer each of the points of your report in turn.
Firstly the job file you provide is roughly correct, in that all you need do with Upstart is provide the path of the executable to be run, rather than having to deal with starting and/or stopping it by hand.
Secondly yes, the fact that your daemon forks is why upstart has lost it. Supervision of forking daemons is planned, and will appear pretty soon (it's mostly just waiting on some code to find the process id of the service that needs supervising). Until that's ready, you'll need to make sure that your daemon doesn't fork into the background.
Thirdly the reason that "start" seems to hang is because jobs define tasks by default, not services. Tasks aren't deemed to be completed until they have stopped running, and thus "start" blocks while it runs. In order to turn your job into a service, which is completed when either running or stopped, you need to change the job file slightly.
service
exec /usr/bin/bspdaemon
Or if the daemon should be respawned automatically if it should die before "stop" is run:
respawn
exec /usr/bin/bspdaemon
I'll leave the bug open as a request for the forking daemon supervision support.