PHP code example of jiromm / react-signal-handler

1. Go to this page and download the library: Download jiromm/react-signal-handler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jiromm / react-signal-handler example snippets




 = \React\EventLoop\Factory::create();
$killer = new React\Signals\Killer\SerialKiller($loop, [SIGTERM, SIGINT]);

$loop->addPeriodicTimer(1, function () {
    echo '.';
});

$killer->onExit(function ($signo, $errno, $code) use ($loop) {
    echo sprintf('[%s] signal received. Waiting 5 seconds.', $signo) . PHP_EOL;
    // ...
    // Do some important stuff
    // ...

    shell_exec('exec sleep 5s');

    $loop->stop();
});

$loop->run();