* Executes a child process with 'proc_open'
*
* @param string $command The command to execute
- * @param array $args Arguments to pass to the command ( [ 'key' => value, 'key2' => value2, ... ]
+ * @param array $args Arguments to pass to the command ( ['arg1', 'arg2', ... ] )
+ * @param array $options Options to pass to the command ( [ 'key' => value, 'key2' => value2, ... ]
*/
- public function run(string $command, array $args)
+ public function run(string $command, array $args = [], array $options = [])
{
if (!function_exists('proc_open')) {
$this->logger->warning('"proc_open" not available - quitting');
$cmdline = $this->config->get('config', 'php_path', 'php') . ' ' . escapeshellarg($command);
- foreach ($args as $key => $value) {
+ foreach ($args as $argumment) {
+ $cmdline .= ' ' . $argumment;
+ }
+
+ foreach ($options as $key => $value) {
if (!is_null($value) && is_bool($value) && !$value) {
continue;
}
if (Worker\Daemon::isMode() && DI::config()->get('system', 'worker_fork')) {
self::forkProcess($do_cron);
} else {
- DI::system()->run('bin/console.php worker', ['no_cron' => !$do_cron]);
+ DI::system()->run('bin/console.php', ['worker'], ['no_cron' => !$do_cron]);
}
if (Worker\Daemon::isMode()) {
Worker\IPC::SetJobState(false);
private static function spawn()
{
Logger::notice('Starting new daemon process');
- DI::system()->run('bin/console.php daemon', ['start']);
+ DI::system()->run('bin/console.php', ['start']);
Logger::notice('New daemon process started');
}
}