eee
This commit is contained in:
@@ -6,6 +6,7 @@ namespace Kiri\Server\Processes;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Process;
|
||||
use const SIGHUP;
|
||||
use const SIGTERM;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -132,10 +133,7 @@ abstract class AbstractProcess implements OnProcessInterface
|
||||
Coroutine::set($array);
|
||||
Coroutine::create(fn() => $this->coroutineWaitSignal());
|
||||
} else {
|
||||
pcntl_signal(\SIGTERM, [$this, 'pointWaitSignal']);
|
||||
pcntl_signal(\SIGINT, [$this, 'pointWaitSignal']);
|
||||
pcntl_signal(\SIGUSR1, [$this, 'pointWaitSignal']);
|
||||
pcntl_signal(SIGHUP, [$this, 'pointWaitSignal']);
|
||||
pcntl_signal(SIGTERM | SIGINT | SIGUSR1, [$this, 'pointWaitSignal']);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@@ -154,21 +152,8 @@ abstract class AbstractProcess implements OnProcessInterface
|
||||
public function pointWaitSignal($signal): void
|
||||
{
|
||||
$this->stop = true;
|
||||
|
||||
$this->onSigterm();
|
||||
switch ($signal) {
|
||||
case \SIGTERM:
|
||||
case \SIGUSR1:
|
||||
case \SIGINT:
|
||||
// some stuff before stop consumer e.g. delete lock etc
|
||||
pcntl_signal($signal, SIG_DFL); // restore handler
|
||||
posix_kill(posix_getpid(), $signal);
|
||||
break; // kill self with signal, see https://www.cons.org/cracauer/sigint.html
|
||||
case SIGHUP:
|
||||
// some stuff to restart consumer
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user