PHP Classes

File: tests/stop.php

Recommend this page to a friend!
  Classes of Wolfy-J   roadrunner   tests/stop.php   Download  
File: tests/stop.php
Role: Example script
Content type: text/plain
Description: Example script
Class: roadrunner
Run multiple tasks of PHP in parallel using Golang
Author: By
Last change:
Date: 6 years ago
Size: 442 bytes
 

Contents

Class file image Download
<?php
/**
 * @var Goridge\RelayInterface $relay
 */

use Spiral\Goridge;
use
Spiral\RoadRunner;

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

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

       
$used = true;
       
$rr->send((string)getmypid());
    } catch (\
Throwable $e) {
       
$rr->error((string)$e);
    }
}