BUG-12465 Se necesita una forma mas sencilla de rehabilitar el cron SOLVED
- No se tenia una opcion para borrar el archivo que se crea con el cron. - se agrega un parametro "+reset", este parametro borra el archivo del cron y se puede continuar directamente con la ejecucion del cron. - php cron.php [+d"YYYY-MM-DD HH:MM:SS"] [+wWORKSPACE] [ACTIVITIES] [+reset]
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
* cron.php
|
* cron.php
|
||||||
* @package workflow-engine-bin
|
* @package workflow-engine-bin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
ini_set('memory_limit', '300M'); // nore: this may need to be higher for many projects
|
ini_set('memory_limit', '300M'); // nore: this may need to be higher for many projects
|
||||||
@@ -58,15 +57,24 @@ $bCronIsRunning = false;
|
|||||||
$sLastExecution = null;
|
$sLastExecution = null;
|
||||||
$processcTimeProcess = 0;
|
$processcTimeProcess = 0;
|
||||||
$processcTimeStart = 0;
|
$processcTimeStart = 0;
|
||||||
|
|
||||||
if (file_exists(PATH_DATA . "cron")) {
|
if (file_exists(PATH_DATA . "cron")) {
|
||||||
|
$reset = false;
|
||||||
|
for ($i = 1; $i <= count($argv) - 1; $i++) {
|
||||||
|
if (strpos($argv[$i], "+reset") !== false) {
|
||||||
|
$reset = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$reset) {
|
||||||
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
||||||
$bCronIsRunning = (boolean)($arrayCron["bCronIsRunning"]);
|
$bCronIsRunning = (boolean)($arrayCron["bCronIsRunning"]);
|
||||||
$sLastExecution = $arrayCron["sLastExecution"];
|
$sLastExecution = $arrayCron["sLastExecution"];
|
||||||
$processcTimeProcess = (isset($arrayCron["processcTimeProcess"]))? intval($arrayCron["processcTimeProcess"]) : 10; //Minutes
|
$processcTimeProcess = (isset($arrayCron["processcTimeProcess"]))? intval($arrayCron["processcTimeProcess"]) : 10; //Minutes
|
||||||
$processcTimeStart = (isset($arrayCron["processcTimeStart"]))? $arrayCron["processcTimeStart"] : 0;
|
$processcTimeStart = (isset($arrayCron["processcTimeStart"]))? $arrayCron["processcTimeStart"] : 0;
|
||||||
|
} else {
|
||||||
|
G::rm_dir(PATH_DATA . "cron");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bCronIsRunning && $processcTimeStart != 0) {
|
if ($bCronIsRunning && $processcTimeStart != 0) {
|
||||||
if ((time() - $processcTimeStart) > ($processcTimeProcess * 60)) {
|
if ((time() - $processcTimeStart) > ($processcTimeProcess * 60)) {
|
||||||
//Cron finished his execution for some reason
|
//Cron finished his execution for some reason
|
||||||
@@ -138,5 +146,6 @@ if (!$bCronIsRunning) {
|
|||||||
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
|
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
|
||||||
} else {
|
} else {
|
||||||
eprintln("The cron is running, please wait for it to finish.\nStarted in $sLastExecution");
|
eprintln("The cron is running, please wait for it to finish.\nStarted in $sLastExecution");
|
||||||
|
eprintln("If do you want force the execution use the command '+reset'" ,"green");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user