I am using php 5.4. I am using gearman and supervisor to control gearman workers. I want to catch the TERM
signal produced by supervisor in PHP. I have the following worker code:
pcntl_signal(SIGTERM, function($sig){
error_log("interrupted", false);
});
while(true){
pcntl_signal_dispatch();
$gw->work();
}
}
My supervisor conf file is as follows:
[program:public_pdf_convert]
process_name = pdf_convert_%(process_num)02d
command = /usr/local/bin/php worker_pdf_convert.php
numprocs = 1
directory = /projects/mv2/deliver/batch/batch/workers/
By default, supervisor use TERM
. When I stop supervisor, I can check that the gearman worker keeps running, but the callback for pcntl_signal
is never called. I have tried with INT
signal also.
来源:https://stackoverflow.com/questions/35979253/pcntl-signal-callbacks-are-not-executed