Skip to content

Commit

Permalink
BUG: Doorman manager child processing fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfendeksilverstripe committed Jun 9, 2020
1 parent 817b1f5 commit 57d3abd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions src/Services/ProcessManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Symbiote\QueuedJobs\Services;

use AsyncPHP\Doorman\Manager\ProcessManager as BaseProcessManager;

/**
* Class ProcessManager
*
* customise shell command to allow child tasks to persist even after manager process is terminated
* this lets the started jobs to finish properly in case the management process terminates
* fore example there are no more jobs to start or queue is paused
*
* @package Symbiote\QueuedJobs\Services
*/
class ProcessManager extends BaseProcessManager
{
/**
* @param string $binary
* @param string $worker
* @param string $stdout
* @param string $stderr
* @return string
*/
protected function getCommand($binary, $worker, $stdout, $stderr) // phpcs:ignore SlevomatCodingStandard.TypeHints
{
return sprintf('nohup %s %s %%s %s %s & echo $!', $binary, $worker, $stdout, $stderr);
}

public function __destruct()
{
// Prevent background tasks from being killed when this script finishes
// this is an override for the default behaviour of killing background tasks
}
}
2 changes: 1 addition & 1 deletion src/Tasks/Engines/DoormanRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Symbiote\QueuedJobs\Tasks\Engines;

use AsyncPHP\Doorman\Manager\ProcessManager;
use SilverStripe\Core\Environment;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\ORM\FieldType\DBDatetime;
use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor;
use Symbiote\QueuedJobs\Jobs\DoormanQueuedJobTask;
use Symbiote\QueuedJobs\Services\ProcessManager;
use Symbiote\QueuedJobs\Services\QueuedJob;
use Symbiote\QueuedJobs\Services\QueuedJobService;

Expand Down

0 comments on commit 57d3abd

Please sign in to comment.