openswoole / ext-openswoole

Programmatic server for PHP with async IO, coroutines and fibers

Home Page:https://openswoole.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onBeforeShutdown issue and Process SIGTERM

EdmondDantes opened this issue · comments

At the moment, OpenSwoole lacks a proper mechanism for terminating workers in the case of a SIGTERM signal. Additionally:

It is not possible to register SIGTERM using Process::signal because an error will occur, indicating that such an event is already registered by someone else (by whom?).

There is no event that would allow stopping processes when the signal has already been received.

Regarding the operation of the Process::signal() method, its workflow is illogical. It is not possible to set a custom handler if someone (within Swoole) has already done so. From the perspective of proper termination, the server should have the ability to terminate the execution of all workers.

PHP Warning: OpenSwoole\Process::signal(): signal [15] processor has been registered by the system in /HttpServer.php on line 368

25361 | | * | 11:11:36 || Server started and ready [OK]
25364 | 1 | T | 11:11:36 || Worker started [OK]
25365 | 0 | R | 11:11:36 || Worker started [OK]

[2023-12-31 13:11:39 #25361.1] INFO Server is shutdown now
[2023-12-31 13:11:42 *25365.0] WARNING Worker_reactor_try_to_exit() (ERRNO 9012): worker exit timeout, forced termination
25365 | 0 | R | 11:11:43 || Worker stop [OK]
25361 | | * | 11:11:43 || Server shutdown [OK]

Otherwise, we get a forced termination, which seems odd.