Discussion:
[Supervisor-users] Child process monitoring
Joris Michaux
2015-02-27 09:05:05 UTC
Permalink
Hello all,

I come to you after 2 days playing with supervisor, and have now a problem
with a PHP daemon witch auto fork into many child process.

My conf :

[program:MyDaemon.php]
command=/usr/bin/pidproxy /var/run/worker/MyDaemon.pid /usr/bin/nohup nice
-n 22 /usr/bin/php -f /data/www/core/bin/MyDaemon.php -- ARG --instance=ARG
--puid=ARG --guid=ARG
redirect_stderr=true
autorestart=true
startsecs=10
startretries=10
stopsignal=TERM
stopasgroup=true
killasgroup=true
priority=1

My result :

19737 ? S 0:00 \_ /usr/bin/python /usr/bin/pidproxy
/var/run/worker/MyWorker.pid /usr/bin/nohup nice -n 22 /usr/bin/php -f
/data/www/core/bin/MyDaemon.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19738 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19743 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19744 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19745 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19746 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG

So it seems that my daemon has been properly monitored, but a stop command
will not kill child process... So supervisor restart my worker with news
childs, and let 4 zombies...

Is my configuration wrong ? Or should I look into the worker code to term
himself his childs ?

Thanks by advance.

Regards,
Joris
Stephane Martin
2015-02-27 14:43:07 UTC
Permalink
i think the problem is that the php program daemonizes itself. so pidproxy
doesn't know anything about the php children.

usually supervisor is mostly useful for programs that run in foreground.
try to disable the "auto daemonize" feature of your php program. if that's
not possible, then you'd better use monit than supervisord.

regards,
stephane
Post by Joris Michaux
Hello all,
I come to you after 2 days playing with supervisor, and have now a problem
with a PHP daemon witch auto fork into many child process.
[program:MyDaemon.php]
command=/usr/bin/pidproxy /var/run/worker/MyDaemon.pid /usr/bin/nohup nice
-n 22 /usr/bin/php -f /data/www/core/bin/MyDaemon.php -- ARG --instance=ARG
--puid=ARG --guid=ARG
redirect_stderr=true
autorestart=true
startsecs=10
startretries=10
stopsignal=TERM
stopasgroup=true
killasgroup=true
priority=1
19737 ? S 0:00 \_ /usr/bin/python /usr/bin/pidproxy
/var/run/worker/MyWorker.pid /usr/bin/nohup nice -n 22 /usr/bin/php -f
/data/www/core/bin/MyDaemon.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19738 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19743 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19744 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19745 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19746 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
So it seems that my daemon has been properly monitored, but a stop command
will not kill child process... So supervisor restart my worker with news
childs, and let 4 zombies...
Is my configuration wrong ? Or should I look into the worker code to term
himself his childs ?
Thanks by advance.
Regards,
Joris
----------
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Jonathan Stewmon
2015-02-27 18:32:41 UTC
Permalink
The daemon process is responsible for trapping the signal from supervisor,
and [in your case, is sounds like you want to] forwarding that signal to
its children.

But, is there a reason why you need to use fork to create the workers?
Supervisor can start as many instances of a program as you want based on
the numprocs program option. If you let supervisor create the workers, it
will manage signaling the worker instances.

On Fri, Feb 27, 2015 at 3:05 AM, Joris Michaux <
Post by Joris Michaux
Hello all,
I come to you after 2 days playing with supervisor, and have now a problem
with a PHP daemon witch auto fork into many child process.
[program:MyDaemon.php]
command=/usr/bin/pidproxy /var/run/worker/MyDaemon.pid /usr/bin/nohup nice
-n 22 /usr/bin/php -f /data/www/core/bin/MyDaemon.php -- ARG --instance=ARG
--puid=ARG --guid=ARG
redirect_stderr=true
autorestart=true
startsecs=10
startretries=10
stopsignal=TERM
stopasgroup=true
killasgroup=true
priority=1
19737 ? S 0:00 \_ /usr/bin/python /usr/bin/pidproxy
/var/run/worker/MyWorker.pid /usr/bin/nohup nice -n 22 /usr/bin/php -f
/data/www/core/bin/MyDaemon.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19738 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19743 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19744 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19745 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19746 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
So it seems that my daemon has been properly monitored, but a stop command
will not kill child process... So supervisor restart my worker with news
childs, and let 4 zombies...
Is my configuration wrong ? Or should I look into the worker code to term
himself his childs ?
Thanks by advance.
Regards,
Joris
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
--
This e-mail, including attachments, contains confidential and/or
proprietary information, and may be used only by the person or entity to
which it is addressed. The reader is hereby notified that any
dissemination, distribution or copying of this e-mail is prohibited. If you
have received this e-mail in error, please notify the sender by replying to
this message and delete this e-mail immediately.
Joris Michaux
2015-03-04 10:40:24 UTC
Permalink
Hi all,

You're right, the daemon is forking himself, but I thought pidproxy was
able to find child processes with pid file. Misunderstood. My bad.

I have no reason to let the process fork himself, it has been written
like that, but I'll ask to modify it to let supervisor manage multiple
instances.

Thanks a lot for yours anwers.

I go back playing with supervisord !!

Regards,
Joris
Post by Jonathan Stewmon
The daemon process is responsible for trapping the signal from supervisor,
and [in your case, is sounds like you want to] forwarding that signal to
its children.
But, is there a reason why you need to use fork to create the workers?
Supervisor can start as many instances of a program as you want based on
the numprocs program option. If you let supervisor create the workers, it
will manage signaling the worker instances.
On Fri, Feb 27, 2015 at 3:05 AM, Joris Michaux <
Post by Joris Michaux
Hello all,
I come to you after 2 days playing with supervisor, and have now a problem
with a PHP daemon witch auto fork into many child process.
[program:MyDaemon.php]
command=/usr/bin/pidproxy /var/run/worker/MyDaemon.pid /usr/bin/nohup nice
-n 22 /usr/bin/php -f /data/www/core/bin/MyDaemon.php -- ARG --instance=ARG
--puid=ARG --guid=ARG
redirect_stderr=true
autorestart=true
startsecs=10
startretries=10
stopsignal=TERM
stopasgroup=true
killasgroup=true
priority=1
19737 ? S 0:00 \_ /usr/bin/python /usr/bin/pidproxy
/var/run/worker/MyWorker.pid /usr/bin/nohup nice -n 22 /usr/bin/php -f
/data/www/core/bin/MyDaemon.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19738 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19743 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19744 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19745 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
19746 ? SN 0:00 \_ /usr/bin/php -f
/data/www/core/bin/MyWorker.php -- ARG --instance=ARG --puid=ARG --guid=ARG
So it seems that my daemon has been properly monitored, but a stop command
will not kill child process... So supervisor restart my worker with news
childs, and let 4 zombies...
Is my configuration wrong ? Or should I look into the worker code to term
himself his childs ?
Thanks by advance.
Regards,
Joris
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
--
*Joris MICHAUX*
Ingénieur systèmes et réseaux
*Skype:* h4mm3r.toxyc
----
425, rue Jean Rostand
31670 Labège, France
*Tel:* +33 (0)5 82 08 07 31
www.france-pari.fr - www.sportnco.com
----
*Social:*
[facebook]
https://www.facebook.com/pages/France-Pari/
[twitter]
https://twitter.com/FrancePari
[linkedin]
http://www.linkedin.com/company/france-pari
[scoop.it]
http://www.scoop.it/t/paris-sportifs-1
Loading...