PHP Classes

File: examples/run_and_keep_running.php

Recommend this page to a friend!
  Classes of Alexandre Sinício   PHP Async Executor   examples/run_and_keep_running.php   Download  
File: examples/run_and_keep_running.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Async Executor
Run PHP scripts in parallel using the CLI version
Author: By
Last change:
Date: 3 years ago
Size: 673 bytes
 

Contents

Class file image Download
<?php
use alesinicio\AsyncExecutor\AsyncExecutor;
use
alesinicio\AsyncExecutor\AsyncMultiProcess;
use
alesinicio\AsyncExecutor\AsyncProcess;

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

//INITIALIZE THE EXECUTOR
$async = new AsyncExecutor('/usr/bin/php');

//INITIALIZE THE MULTI-INSTANCE WRAPPER
$multiAsync = new AsyncMultiProcess($async);

//ADD PROCESSES TO BE MANAGED BY THE MULTI-INSTANCE HANDLER
$multiAsync->addProcess(new AsyncProcess('instance_01', __DIR__.'/bg_process.php', ['param01']));
$multiAsync->addProcess(new AsyncProcess('instance_02', __DIR__.'/bg_process.php', ['param02', 'param03']));

//RUN THE SCRIPTS FOREVER
$multiAsync->keepRunningProcesses();