summaryrefslogtreecommitdiff
path: root/tests/stop.php
blob: 93263821e971b052f9295ff0532363b0a0d15c98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
/**
 * @var Goridge\RelayInterface $relay
 */

use Spiral\Goridge;
use Spiral\RoadRunner;

$rr = new RoadRunner\Worker($relay);

$used = false;
while ($in = $rr->waitPayload()) {
    try {
        if ($used) {
            // kill on second attempt
            $rr->stop();
            continue;
        }

        $used = true;
        $rr->respond(new RoadRunner\Payload((string)getmypid()));
    } catch (\Throwable $e) {
        $rr->error((string)$e);
    }
}