1
votes

Few days ago I found out that my webapp wrote ontop of the tornadoweb framework doesn't stop or restart via upstart. Upstart just hangs and doesn't do anything.

I investigated the issue and found that upstart recieves wrong PID, so it can only run once my webapp daemon and can't do anything else.

Strace shows that my daemon makes 4 (!) clone() calls instead of 2.

Week ago anything was good and webapp was fully and correctly managed by the upstart.

OS is Ubuntu 10.04.03 LTS (as it was weeks ago).

Do you have any ideas how to fix it?

PS: I know about "expect fork|daemon" directive, it changes nothing ;)

2
Can you post your upstart script?Ismail Badawi

2 Answers

1
votes

Sorry my silence, please.

Investigation of the issue ended with the knowledge about uuid python library which adds 2 forks to my daemon. I get rid of this lib and tornado daemon works now properly.

Alternative answer was supervisord which can run any console tools as a daemon which can't daemonize by itself.

0
votes

There are two often used solutions

The first one is to let your application honestly report its pid. If you could force your application to write the actual pid into the pidfile then you could get its pid from there.

The second one is a little more complicated. You may add specific environment variable for the script invocation. This environment variable will stay with all the forks if forks don't clear environment and than you can find all of your processes by parsing /proc/*/environ files.

There should be easier solution for finding processes by their environment but I'm not sure.