PHP-Daemon
PHP-Daemon copied to clipboard
ON_SHUTDOWN hook not called during automatic restart
In my application I have registered a handler for the ON_SHUTDOWN hook, which cleans up some network connections. During regular shutdown, the hook is executed fine, but when the daemon is automatically restarted, the hook is not called, resulting in lingering connections.
The reason for this is that the hook is dispatched from the destructor of the Daemon class, which in the case of an automatic restart is called when the exit
call is made in the restart()
method. Unfortunately, for non-intuitive reasons, right before the exit
call is made, the array containing all the callbacks is cleared, so once the destructor runs, there aren't any hooks leftover to call.
I see that this has been fixed in the more recent versions (2.1+). Could you please create a new tag for the stable versions, so packagist can pull them in? That makes it much easier to upgrade them. Thanks a lot!