/** * @param SignalEvent $event */ public function stop(SignalEvent $event) { if (!in_array($event->data()['signal'], [SIGTERM, SIGINT])) { return; } $event->getLoop()->stop(); }
/** * @param WebsocketStartEvent $event */ public function start(WebsocketStartEvent $event) { $this->pcntl = new PCNTL($event->getLoop()); foreach ($this->signals as $signal) { $this->pcntl->on($signal, function ($signal) use($event) { EventManager::instance()->dispatch(SignalEvent::create($event->getLoop(), $signal)); }); } }