# Signal handler The signal handler will listen to the `Worker` process and the `custom` process and automatically register with the signal manager after it starts. ## Install ``` composer require hyperf/signal ``` ## Publish configuration You can publish the default configuration file to your project with the following command: ```bash php bin/hyperf.php vendor:publish hyperf/signal ``` ## Add handler Below we listen to the `SIGTERM` signal of the `Worker` process, and print the signal value when the signal is received. ```php WorkerStopHandler is not suitable for CoroutineServer, please implement it yourself if necessary ```php [ Hyperf\Signal\Handler\WorkerStopHandler::class => PHP_INT_MIN ], 'timeout' => 5.0, ]; ``` After the `WorkerStopHandler` is triggered, it will close the current process after the set [max_wait_time](https://wiki.swoole.com/#/server/setting?id=max_wait_time) configuration time. ## Coroutine style service listener configuration example > The above default listeners are all adapted to asynchronous style services. If you need to use them in coroutine style services, you can customize the configuration as follows ```php container = $container; $this->config = $container->get(ConfigInterface::class); } public function listen(): array { // There is only one Worker process in the coroutine style, so you only need to monitor the WORKER here. return [ [self::WORKER, SIGTERM], [self::WORKER, SIGINT], ]; } public function handle(int $signal): void { ProcessManager::setRunning(false); foreach (ServerManager::list() as [$type, $server]) { // Cyclically close open services $server->shutdown(); } } } ```