E
E
Egor Petrov2015-10-13 14:34:22
PHP
Egor Petrov, 2015-10-13 14:34:22

How can I force supervisord to wait for a graceful termination of a process?

I use supervisord to daemonize PHP processes. The daemon can request something for some API for a long time, and at this moment someone may need to increase the number of some processes and it will restart everything. Or just someone might click restart the daemon while the daemon is doing important work.
I assign the handler pcntl_signal(SIGTERM, "handler"); in the handler I specify for the 15th signal not to call exit, but the process is still restarted, its pid changes.
If I run from the console and intercept signal 2, ctrl+c, then it works fine, the process does not stop.
Here's the question - how can I make the supervisor wait from PHP code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
developinwed, 2015-10-22
@developinwed

As far as I understand, you need a "soft restart" (reload). The supervisor restarts the process, it won't reload you the way you want. Here is an excellent article on soft restart from Badoo habrahabr.ru/company/badoo/blog/252809 , with sources on github https://github.com/badoo/habr/tree/master/phprocksyd . But there you need to patch PHP, which is not always possible.
Describe in more detail what your daemon does, is it possible to fork your process and process tasks in forks?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question