PMCORE-1759

fix observations

u
This commit is contained in:
Henry Jordan
2020-07-07 16:06:59 +00:00
parent a6d127b77c
commit ccbd3e87d5
2 changed files with 26 additions and 18 deletions

View File

@@ -1,17 +1,12 @@
<?php <?php
namespace App\Console\Commands; namespace App\Console\Commands;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Console\Scheduling\ScheduleRunCommand as BaseCommand; use Illuminate\Console\Scheduling\ScheduleRunCommand as BaseCommand;
use Maveriks\WebApplication; use Maveriks\WebApplication;
use ProcessMaker\Model\TaskScheduler; use ProcessMaker\Model\TaskScheduler;
class ScheduleRunCommand extends BaseCommand class ScheduleRunCommand extends BaseCommand
{ {
use AddParametersTrait; use AddParametersTrait;
/** /**
* Create a new command instance. * Create a new command instance.
* *
@@ -30,7 +25,6 @@ class ScheduleRunCommand extends BaseCommand
$this->description .= ' (ProcessMaker has extended this command)'; $this->description .= ' (ProcessMaker has extended this command)';
parent::__construct($schedule); parent::__construct($schedule);
} }
/** /**
* Execute the console command. * Execute the console command.
* *
@@ -47,12 +41,15 @@ class ScheduleRunCommand extends BaseCommand
$webApplication->loadEnvironment($workspace, false); $webApplication->loadEnvironment($workspace, false);
} }
TaskScheduler::all()->each(function ($p) use ($that, $user) { TaskScheduler::all()->each(function ($p) use ($that, $user) {
$win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
if ($p->enable == 1) { if ($p->enable == 1) {
$starting = isset($p->startingTime) ? $p->startingTime : "0:00"; $starting = isset($p->startingTime) ? $p->startingTime : "0:00";
$ending = isset($p->startingTime) ? $p->endingTime : "23:59"; $ending = isset($p->startingTime) ? $p->endingTime : "23:59";
$timezone = isset($p->timezone) && $p->timezone != "" ? $p->timezone : date_default_timezone_get(); $timezone = isset($p->timezone) && $p->timezone != "" ? $p->timezone : date_default_timezone_get();
$body = $p->body;
if (!$win) {
$body = str_replace(" -c"," " . $user . " -c", $p->body); $body = str_replace(" -c"," " . $user . " -c", $p->body);
}
$that->schedule->exec($body)->cron($p->expression)->between($starting, $ending)->timezone($timezone)->when(function () use ($p) { $that->schedule->exec($body)->cron($p->expression)->between($starting, $ending)->timezone($timezone)->when(function () use ($p) {
$now = Carbon::now(); $now = Carbon::now();
$result = false; $result = false;

View File

@@ -1,10 +1,7 @@
<?php <?php
namespace ProcessMaker\BusinessModel; namespace ProcessMaker\BusinessModel;
use ProcessMaker\Core\System; use ProcessMaker\Core\System;
use ProcessMaker\Model\TaskScheduler; use ProcessMaker\Model\TaskScheduler;
class TaskSchedulerBM class TaskSchedulerBM
{ {
public static $services = [ public static $services = [
@@ -14,6 +11,7 @@ class TaskSchedulerBM
"service" => "unpause", "service" => "unpause",
"category" => "case_actions", "category" => "case_actions",
"file" => "workflow/engine/bin/cron.php", "file" => "workflow/engine/bin/cron.php",
"filew" => "workflow\\engine\bin\cron.php",
"startingTime" => null, "startingTime" => null,
"endingTime" => null, "endingTime" => null,
"everyOn" => "1", "everyOn" => "1",
@@ -27,6 +25,7 @@ class TaskSchedulerBM
"service" => "calculate", "service" => "calculate",
"category" => "case_actions", "category" => "case_actions",
"file" => "workflow/engine/bin/cron.php", "file" => "workflow/engine/bin/cron.php",
"filew" => "workflow\\engine\bin\cron.php",
"startingTime" => "0:00", "startingTime" => "0:00",
"endingTime" => "0:30", "endingTime" => "0:30",
"everyOn" => "1", "everyOn" => "1",
@@ -40,6 +39,7 @@ class TaskSchedulerBM
"service" => "unassigned-case", "service" => "unassigned-case",
"category" => "case_actions", "category" => "case_actions",
"file" => "workflow/engine/bin/cron.php", "file" => "workflow/engine/bin/cron.php",
"filew" => "workflow\\engine\bin\cron.php",
"startingTime" => null, "startingTime" => null,
"endingTime" => null, "endingTime" => null,
"everyOn" => "1", "everyOn" => "1",
@@ -53,6 +53,7 @@ class TaskSchedulerBM
"service" => "clean-self-service-tables", "service" => "clean-self-service-tables",
"category" => "case_actions", "category" => "case_actions",
"file" => "workflow/engine/bin/cron.php", "file" => "workflow/engine/bin/cron.php",
"filew" => "workflow\\engine\bin\cron.php",
"startingTime" => "0:00", "startingTime" => "0:00",
"endingTime" => "0:30", "endingTime" => "0:30",
"everyOn" => "1", "everyOn" => "1",
@@ -66,6 +67,7 @@ class TaskSchedulerBM
"service" => "emails", "service" => "emails",
"category" => "emails_notifications", "category" => "emails_notifications",
"file" => "workflow/engine/bin/cron.php", "file" => "workflow/engine/bin/cron.php",
"filew" => "workflow\\engine\bin\cron.php",
"startingTime" => null, "startingTime" => null,
"endingTime" => null, "endingTime" => null,
"everyOn" => "1", "everyOn" => "1",
@@ -79,6 +81,7 @@ class TaskSchedulerBM
"service" => "", "service" => "",
"category" => "emails_notifications", "category" => "emails_notifications",
"file" => "workflow/engine/bin/actionsByEmailEmailResponse.php", "file" => "workflow/engine/bin/actionsByEmailEmailResponse.php",
"filew" => "workflow\\engine\bin\actionsByEmailEmailResponse.php",
"startingTime" => null, "startingTime" => null,
"endingTime" => null, "endingTime" => null,
"everyOn" => "1", "everyOn" => "1",
@@ -92,6 +95,7 @@ class TaskSchedulerBM
"service" => "", "service" => "",
"category" => "emails_notifications", "category" => "emails_notifications",
"file" => "workflow/engine/bin/messageeventcron.php", "file" => "workflow/engine/bin/messageeventcron.php",
"filew" => "workflow\\engine\bin\messageeventcron.php",
"startingTime" => null, "startingTime" => null,
"endingTime" => null, "endingTime" => null,
"everyOn" => "1", "everyOn" => "1",
@@ -105,6 +109,7 @@ class TaskSchedulerBM
"service" => "", "service" => "",
"category" => "emails_notifications", "category" => "emails_notifications",
"file" => "workflow/engine/bin/sendnotificationscron.php", "file" => "workflow/engine/bin/sendnotificationscron.php",
"filew" => "workflow\\engine\bin\sendnotificationscron.php",
"startingTime" => null, "startingTime" => null,
"endingTime" => null, "endingTime" => null,
"everyOn" => "1", "everyOn" => "1",
@@ -118,6 +123,7 @@ class TaskSchedulerBM
"service" => "report_by_user", "service" => "report_by_user",
"category" => "reporting", "category" => "reporting",
"file" => "workflow/engine/bin/cron.php", "file" => "workflow/engine/bin/cron.php",
"filew" => "workflow\\engine\bin\cron.php",
"startingTime" => null, "startingTime" => null,
"endingTime" => null, "endingTime" => null,
"everyOn" => "1", "everyOn" => "1",
@@ -131,9 +137,9 @@ class TaskSchedulerBM
"service" => "report_by_process", "service" => "report_by_process",
"category" => "reporting", "category" => "reporting",
"file" => "workflow/engine/bin/cron.php", "file" => "workflow/engine/bin/cron.php",
"filew" => "workflow\\engine\bin\cron.php",
"startingTime" => null, "startingTime" => null,
"category" => "reporting", "category" => "reporting",
"file" => "workflow/engine/bin/cron.php",
"startingTime" => null, "startingTime" => null,
"endingTime" => null, "endingTime" => null,
"everyOn" => "1", "everyOn" => "1",
@@ -147,6 +153,7 @@ class TaskSchedulerBM
"service" => "", "service" => "",
"category" => "processmaker_sync", "category" => "processmaker_sync",
"file" => "workflow/engine/bin/ldapcron.php", "file" => "workflow/engine/bin/ldapcron.php",
"filew" => "workflow\\engine\bin\ldapcron.php",
"startingTime" => "0:00", "startingTime" => "0:00",
"endingTime" => "0:30", "endingTime" => "0:30",
"everyOn" => "1", "everyOn" => "1",
@@ -160,6 +167,7 @@ class TaskSchedulerBM
"service" => "plugins", "service" => "plugins",
"category" => "plugins", "category" => "plugins",
"file" => "workflow/engine/bin/cron.php", "file" => "workflow/engine/bin/cron.php",
"filew" => "workflow\\engine\bin\cron.php",
"startingTime" => "0:00", "startingTime" => "0:00",
"endingTime" => "0:30", "endingTime" => "0:30",
"everyOn" => "1", "everyOn" => "1",
@@ -173,6 +181,7 @@ class TaskSchedulerBM
"service" => "", "service" => "",
"category" => "case_actions", "category" => "case_actions",
"file" => "workflow/engine/bin/timereventcron.php", "file" => "workflow/engine/bin/timereventcron.php",
"filew" => "workflow\\engine\bin\\timereventcron.php",
"startingTime" => null, "startingTime" => null,
"endingTime" => null, "endingTime" => null,
"everyOn" => "1", "everyOn" => "1",
@@ -207,7 +216,6 @@ class TaskSchedulerBM
if (isset($request['enable'])) { if (isset($request['enable'])) {
$task->enable = $request['enable']; $task->enable = $request['enable'];
} }
if (isset($request['expression'])) { if (isset($request['expression'])) {
$task->expression = $request['expression']; $task->expression = $request['expression'];
$task->startingTime = $request['startingTime']; $task->startingTime = $request['startingTime'];
@@ -219,7 +227,6 @@ class TaskSchedulerBM
$task->save(); $task->save();
return $task; return $task;
} }
/** /**
* Initial data for Schedule Table, with default values * Initial data for Schedule Table, with default values
*/ */
@@ -227,7 +234,7 @@ class TaskSchedulerBM
{ {
$arraySystemConfiguration = System::getSystemConfiguration('', '', config("system.workspace")); $arraySystemConfiguration = System::getSystemConfiguration('', '', config("system.workspace"));
$toSave = []; $toSave = [];
$win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
foreach (TaskSchedulerBM::$services as $service) { foreach (TaskSchedulerBM::$services as $service) {
$task = new TaskScheduler; $task = new TaskScheduler;
$task->title = $service["title"]; $task->title = $service["title"];
@@ -235,7 +242,11 @@ class TaskSchedulerBM
$task->description = $service["description"]; $task->description = $service["description"];
$task->startingTime = $service["startingTime"]; $task->startingTime = $service["startingTime"];
$task->endingTime = $service["endingTime"]; $task->endingTime = $service["endingTime"];
if ($win) {
$task->body = 'php "' . PATH_TRUNK . $service["filew"] . '" ' . $service["service"] . ' +w' . config("system.workspace") . ' +force';
} else {
$task->body = 'su -s /bin/sh -c "php ' . PATH_TRUNK . $service["file"] . " " . $service["service"] . ' +w' . config("system.workspace") . ' +force"'; $task->body = 'su -s /bin/sh -c "php ' . PATH_TRUNK . $service["file"] . " " . $service["service"] . ' +w' . config("system.workspace") . ' +force"';
}
$task->expression = $service["expression"]; $task->expression = $service["expression"];
$task->type = "shell"; $task->type = "shell";
$task->system = 1; $task->system = 1;