How to start script many times at same time
xenion54 opened this issue · 2 comments
xenion54 commented
On windows i can run script with same name multiple times (with different params). On linux, this doesn't work. After start first script, others scripts not starting. Event onWorkerStart called just first time. How can i run same script multiple times in linux?
<?php
use Workerman\Connection\TcpConnection;
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Libs' . DIRECTORY_SEPARATOR . 'init.php';
$args = getopt('', ['port:']);
global $argv;
$argv[1] = 'start';
$argv[2] = '-d';
$sw = new \Workerman\Worker('websocket://0.0.0.0:' . $args['port']);
$sw->count = 1;
$sw->onWorkerStart = function (\Workerman\Worker $worker) {
echo $args['arg1'] . PHP_EOL; // this line called only once
};
\Workerman\Worker::runAll();
walkor commented
<?php
use Workerman\Connection\TcpConnection;
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Libs' . DIRECTORY_SEPARATOR . 'init.php';
$args = getopt('', ['port:']);
global $argv;
$argv[1] = 'start';
$argv[2] = '-d';
// The key
\Workerman\Worker::$pidFile= __DIR__ . '/worker.' . $args['port'] . '.pid';
$sw = new \Workerman\Worker('websocket://0.0.0.0:' . $args['port']);
$sw->count = 1;
$sw->onWorkerStart = function (\Workerman\Worker $worker) {
echo $args['arg1'] . PHP_EOL; // this line called only once
};
\Workerman\Worker::runAll();