pcntl_signal callbacks are not executed

余生颓废 提交于 2019-12-22 17:54:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!