Skip to content

Instantly share code, notes, and snippets.

@ekinhbayar
Created April 24, 2018 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekinhbayar/f89c5a4b87a6179784d56327b87adef7 to your computer and use it in GitHub Desktop.
Save ekinhbayar/f89c5a4b87a6179784d56327b87adef7 to your computer and use it in GitHub Desktop.
$signalHandler = function ( $signal ) use ( $refreshWatcher, $clearWatcher ) {
Loop::cancel( $refreshWatcher );
Loop::cancel( $clearWatcher );
Loop::stop();
print "Caught {$signal}, exiting...\n";
//exit;
};
try {
Loop::onSignal( SIGINT, $signalHandler, "SIGINT" );
Loop::onSignal( SIGTERM, $signalHandler, "SIGTERM" );
} catch ( \Throwable $e ) {
echo "Err: " . $e->getMessage();
}
Loop::run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment