Skip to content

Commit

Permalink
Adapt run-command for console.php executions
Browse files Browse the repository at this point in the history
  • Loading branch information
nupplaphil committed Jan 2, 2025
1 parent 4e13c6a commit 6934244
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/Core/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ public function isMaxLoadReached(): bool
* 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');
Expand All @@ -175,7 +176,11 @@ public function run(string $command, array $args)

$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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ public static function spawnWorker(bool $do_cron = false)
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);
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Worker/Daemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static function checkState()
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');
}
}

0 comments on commit 6934244

Please sign in to comment.