How do I catch a UNIX TERM Signal so I can gracefully terminate a PHP
process?
I'm running many PHP processes via Supervisord. Sometimes I need to shut
Supervisord down. When I do so, I have it set to send a TERM signal to all
the PHP processes it has spawned. I'd like to intercept that TERM Signal
and gracefully terminate the PHP process. Can this be done?
I've added this code to my PHP program to try and do this:
declare( ticks = 1 );
function gracefully_terminate() {
echo "\n\ngracefully terminating\n\n";
}
pcntl_signal( SIGTERM, "gracefully_terminate" );
Also ... how to I send a TERM signal to a PHP process via the CLI? I've
tried using Kill -s TERM #####. Perhaps this is sending the TERM signal,
but it's not terminating the PHP process.
No comments:
Post a Comment