Skip to content

Commit

Permalink
feat: start execute command with shell exec
Browse files Browse the repository at this point in the history
  • Loading branch information
rugbymauri committed Sep 4, 2023
1 parent 400421a commit ee4e1c2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Manager/ExecutionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,13 @@ public function getPendingExecution(CronInterface $cronJob)

protected function schedule(CronInterface $cronJob): void
{
$this->logger->info(sprintf('Scheduling execution of %s', $cronJob::class));
$process = new Process([$this->projectDir . '/bin/console', 'whatwedo:cron:execute', str_replace('\\', '\\\\', $cronJob::class), '-e', $this->environment]);
$process->run();
$this->logger->debug(sprintf('Helper process running with PID %d', $process->getPid()));
$this->logger->debug(sprintf('Scheduling execution of %s', $cronJob::class));
$command = [$this->projectDir . '/bin/console', 'whatwedo:cron:execute', str_replace('\\', '\\\\', $cronJob::class), '-e', $this->environment];
$this->logger->debug(sprintf('Scheduling execution of %s Command: %s', $cronJob::class, implode(' ', $command) ));

// https://www.geeksforgeeks.org/how-to-execute-a-background-process-in-php/
$processId = shell_exec(implode(' ', $command) . ' > /dev/null 2>&1 & echo $!');
$this->logger->debug(sprintf('Execute process running: PID: %s', $processId));
}

protected function cleanupPending(CronInterface $cronJob): void
Expand Down

0 comments on commit ee4e1c2

Please sign in to comment.