Process\Pool kill -s SIGUSR1 不能热重启?

$pool = new Swoole\Process\Pool(2);
$pool->on("WorkerStart", function ($pool, $workerId) {
    if($workerId == 0){
        cli_set_process_title("swoole:timers");
        $timer_id = Swoole\Timer::tick(2000,function($timer_id){
            Swoole\Process::signal(SIGTERM,function()use($timer_id){
                Swoole\Timer::clear($timer_id);
            });
            Swoole\Process::signal(SIGUSR1,function()use($timer_id){
                Swoole\Timer::clear($timer_id);
            });
            $redis = new Redis();
            $redis->connect('127.0.0.1', 6379);
            $redis->lpush('task',date('Y-m-d H:i:s'));
        });
    }else{
        cli_set_process_title("swoole:workers");
        $running = true;
        pcntl_signal(SIGTERM, function () use (&$running) {
            $running = false;
        });
        pcntl_signal(SIGUSR1, function () use (&$running) {
            $running = false;
        });
        $redis = new Redis();
        $redis->pconnect('127.0.0.1', 6379);
        while ($running) {
            pcntl_signal_dispatch();
            $msgs = $redis->brpop('task', 2);
            if ( $msgs == null) continue;
            file_put_contents('/tmp/timer.log', $msgs[1].PHP_EOL,FILE_APPEND);
        }    
    }

});
$pool->on("WorkerStop", function ($pool, $workerId) {
    file_put_contents('/tmp/timer.log', "Worker#{$workerId} is stopped".PHP_EOL,FILE_APPEND);
});
cli_set_process_title("swoole:master");
Swoole\Process::daemon(true, true);
$pool->start();

以下是strace 主进程id的结果:

9583 wait4(-1, 0x7ffec8c6868c, 0, NULL) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) 9583 --- SIGUSR1 {si_signo=SIGUSR1, si_code=SI_USER, si_pid=8987, si_uid=0} --- 9583 rt_sigaction(SIGUSR1, NULL, {0x61e240, ~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1], SA_RESTORER|SA_SIGINFO, 0x7f8a1bdea570}, 8) = 0 9583 rt_sigaction(SIGUSR1, {SIG_DFL, [], SA_RESTORER|SA_SIGINFO, 0x7f8a1bdea570}, NULL, 8) = 0 9583 rt_sigprocmask(SIG_UNBLOCK, [USR1], NULL, 8) = 0 9583 kill(9583, SIGUSR1) = 0 9583 --- SIGUSR1 {si_signo=SIGUSR1, si_code=SI_USER, si_pid=9583, si_uid=0} --- 9583 +++ killed by SIGUSR1 +++

2018-07-23 14:15
0

要回复问题请先登录注册