9951 explained code solutions for 126 technologies

php-swooleHow to shutdown Swoole server from program.

$srv = new Swoole\Server('', 81);

$srv->on('receive', function ($srv, $fd, $from_id, $data)
    if ( trim($data) == 'off' ) {

$srv->start();ctrl + c
new Swoole\Server

init Swoole server object, listening on localhost:81


handle event when client send us request


let's shut down the server if we receive off from client


shuts down server