use pcntl only in cli mode

This commit is contained in:
Evgeny Zinoviev 2023-04-13 15:21:18 +03:00
parent a788befa6b
commit b3db543c43

View File

@ -51,9 +51,11 @@ abstract class Job extends model {
public function __construct(array $raw) {
parent::__construct($raw);
pcntl_async_signals(true);
pcntl_signal(SIGTERM, [$this, 'signalHandler']);
pcntl_signal(SIGINT, [$this, 'signalHandler']);
if (PHP_SAPI === 'cli') {
pcntl_async_signals(true);
pcntl_signal(SIGTERM, [$this, 'signalHandler']);
pcntl_signal(SIGINT, [$this, 'signalHandler']);
}
}
protected function signalHandler(int $signal) {}