Restarting Workers

RoadRunner provides multiple ways to safely restart worker(s) on demand. Both approaches can be used on a live server and should not cause downtime.

Stop Command

You are able to send stop command from worker to parent server to force process destruction. In this scenario, the job/request will be automatically forwarded to the next worker.

We can demonstrate it by implementing max_jobs control on PHP end:


use Spiral\RoadRunner;
use Nyholm\Psr7;

include "vendor/autoload.php";

$worker = RoadRunner\Worker::create();
$psrFactory = new Psr7\Factory\Psr17Factory();

$worker = new RoadRunner\Http\PSR7Worker($worker, $psrFactory, $psrFactory, $psrFactory);

$count = 0;
while ($req = $worker->waitRequest()) {
    try {
        $rsp = new Psr7\Response();
        $rsp->getBody()->write('Hello world!');

        if ($count > 10) {

    } catch (\Throwable $e) {

This approach can be used to control memory usage inside the PHP script.

Full Reset

You can also initiate a rebuild of all RoadRunner workers using embedded RPC bus:

$rpc = \Spiral\Goridge\RPC\RPC::create('tcp://');
$rpc->call('resetter.Reset', 'http');
Edit this page