Skip to content

Commit 5b4be2c

Browse files
author
Michael Miscampbell
committed
Adding ProcessID to the BackgoundTask table
Fixing issue on BackgroundTask where the function setShellArguments was being called with no arguments which caused the script to fail with a warning
1 parent 9182502 commit 5b4be2c

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
* TODO: Windows support
66
* TODO: Restore PhpIdeConfig setting to allow debugging of running background tasks
77

8+
### 1.1.2
9+
10+
* FIXED: Fixed issue that caused the executing script to fail
11+
* ADDED: Added the ProcessID that is currently being ran to the Background Task table
12+
813
### 1.1.1
914
* UPDATED: rhubarb_app environment setting support to allow background tasks to work in new environment
1015

src/Models/BackgroundTaskStatus.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
namespace Rhubarb\Scaffolds\BackgroundTasks\Models;
2020

2121
use Rhubarb\Crown\Exceptions\RhubarbException;
22+
use Rhubarb\Scaffolds\BackgroundTasks\BackgroundTask;
2223
use Rhubarb\Stem\Models\Model;
2324
use Rhubarb\Stem\Repositories\MySql\Schema\Columns\MySqlEnumColumn;
2425
use Rhubarb\Stem\Schema\Columns\AutoIncrementColumn;
2526
use Rhubarb\Stem\Schema\Columns\DecimalColumn;
27+
use Rhubarb\Stem\Schema\Columns\IntegerColumn;
2628
use Rhubarb\Stem\Schema\Columns\JsonColumn;
2729
use Rhubarb\Stem\Schema\Columns\LongStringColumn;
2830
use Rhubarb\Stem\Schema\Columns\StringColumn;
@@ -37,6 +39,7 @@
3739
* @property string $TaskStatus The status of the task: Running, Complete or Failed
3840
* @property string $ExceptionDetails If the task failed, exception details will be contained here.
3941
* @property \stdClass $TaskSettings Settings to be passed to the task, stored as JSON
42+
* @property int $ProcessID The PID for the background task process when it is executed
4043
*/
4144
class BackgroundTaskStatus extends Model
4245
{
@@ -63,7 +66,8 @@ protected function createSchema()
6366
new DecimalColumn("PercentageComplete", 5, 2, 0),
6467
new StringColumn("Message", 200),
6568
new LongStringColumn("ExceptionDetails"),
66-
new JsonColumn("TaskSettings", null, true)
69+
new JsonColumn("TaskSettings", null, true),
70+
new IntegerColumn("ProcessID")
6771
);
6872

6973
return $schema;
@@ -78,10 +82,10 @@ protected function createSchema()
7882
public function start()
7983
{
8084
$class = $this->TaskClass;
85+
/** @var BackgroundTask $task */
8186
$task = new $class();
8287

8388
try {
84-
$task->setShellArguments();
8589
$task->execute($this);
8690

8791
$this->TaskStatus = "Complete";

src/Models/BackgroundTasksSolutionSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BackgroundTasksSolutionSchema extends SolutionSchema
2626
{
2727
public function __construct()
2828
{
29-
parent::__construct(0.12);
29+
parent::__construct(0.13);
3030

3131
$this->addModel("BackgroundTaskStatus", __NAMESPACE__ . '\BackgroundTaskStatus');
3232
}

src/Scripts/task-runner.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
namespace Rhubarb\Scaffolds\BackgroundTasks\Scripts;
2020

21+
use Rhubarb\Scaffolds\BackgroundTasks\BackgroundTask;
2122
use Rhubarb\Scaffolds\BackgroundTasks\Models\BackgroundTaskStatus;
2223

2324
$taskClass = $argv[2];
@@ -36,6 +37,7 @@
3637
// See docs for more details on passing shell arguments.
3738
$additionalArguments = array_slice($argv, 4);
3839

40+
/** @var BackgroundTask $taskClass */
3941
$taskClass::setShellArguments($additionalArguments);
4042

4143
$pid = pcntl_fork();

0 commit comments

Comments
 (0)