eee
This commit is contained in:
@@ -17,6 +17,8 @@ abstract class AbstractProcess implements OnProcessInterface
|
||||
|
||||
private bool $stop = false;
|
||||
|
||||
private bool $stopping = false;
|
||||
|
||||
|
||||
public Process $process;
|
||||
|
||||
@@ -132,10 +134,11 @@ abstract class AbstractProcess implements OnProcessInterface
|
||||
$array['deadlock_check_disable_trace'] = false;
|
||||
$array['exit_condition'] = [$this, 'exit_condition'];
|
||||
Coroutine::set($array);
|
||||
$process::signal(SIGINT, static function (): void {});
|
||||
Coroutine::create(fn() => $this->coroutineWaitSignal());
|
||||
} else {
|
||||
$process::signal(SIGTERM, [$this, 'pointWaitSignal']);
|
||||
$process::signal(SIGINT, [$this, 'pointWaitSignal']);
|
||||
$process::signal(SIGINT, static function (): void {});
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@@ -153,9 +156,7 @@ abstract class AbstractProcess implements OnProcessInterface
|
||||
*/
|
||||
public function pointWaitSignal($signal): void
|
||||
{
|
||||
$this->stop = true;
|
||||
|
||||
$this->onSigterm();
|
||||
$this->requestStop();
|
||||
}
|
||||
|
||||
|
||||
@@ -164,10 +165,20 @@ abstract class AbstractProcess implements OnProcessInterface
|
||||
*/
|
||||
public function coroutineWaitSignal(): void
|
||||
{
|
||||
$value = Coroutine::waitSignal(SIGTERM);
|
||||
if ($value) {
|
||||
$this->stop = true;
|
||||
Coroutine::waitSignal(SIGTERM);
|
||||
$this->requestStop();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function requestStop(): void
|
||||
{
|
||||
if ($this->stopping) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->stopping = true;
|
||||
$this->stop = true;
|
||||
$this->onSigterm();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user