reactphp-x/process-manager

v0.0.6 2024-08-14 00:38 UTC

This package is auto-updated.

Last update: 2024-11-07 02:51:03 UTC


README

isntall

composer require reactphp-x/process-manager -vvv

Usage

require __DIR__ . '/../vendor/autoload.php';

use ReactphpX\ProcessManager\ProcessManager;

ProcessManager::$debug = true;

$stream = ProcessManager::instance('cron')->call(function($stream) {
    return 'hello world cron';
});

$stream->on('data', function($data) {
    echo $data.PHP_EOL;
});

$stream->on('close', function() {
    echo 'closed'.PHP_EOL;
});

other handle in different process

require __DIR__ . '/../vendor/autoload.php';

use ReactphpX\ProcessManager\ProcessManager;

ProcessManager::$debug = true;

$stream = ProcessManager::instance('queue')->call(function($stream) {
    return 'hello world queue';
});

$stream->on('data', function($data) {
    echo $data.PHP_EOL;
});

$stream->on('close', function() {
    echo 'closed'.PHP_EOL;
});

set process boot file

// see example/02.php
ProcessManager::instance('queue')->setBootFile(__DIR__.'/boot.php');

set process number

ProcessManager::instance('queue')->setNumber(10);

$stream = ProcessManager::instance('queue')->call(function($stream) {
    return 'hello world queue';
});
$stream->on('data', function($data) {
    echo $data.PHP_EOL;
});

$stream->on('close', function() {
    echo 'closed'.PHP_EOL;
});

var_dump(ProcessManager::instance('queue')->getInfo());

License

MIT