BUG-00000 "El script cron.php puede ser ejecutado varias veces" SOLVED
Issue:
El script cron.php puede ser ejecutado varias veces
Cause:
El archivo bandera "cron" trabaja bien en Windows y no asi en Linux
Solution:
- Se ha agregado nuevas validaciones para entornos Linux
Ejemplo: ps -fea | grep cron.php | grep -v grep
- Se ha mejorado el codigo
This commit is contained in:
@@ -54,33 +54,47 @@ $bCronIsRunning = false;
|
||||
$sLastExecution = null;
|
||||
$processcTimeProcess = 0;
|
||||
$processcTimeStart = 0;
|
||||
if (file_exists(PATH_DATA . "cron")) {
|
||||
$force = false;
|
||||
for ($i = 1; $i <= count($argv) - 1; $i++) {
|
||||
if (strpos($argv[$i], "+force") !== false) {
|
||||
$force = true;
|
||||
unset($argv[$i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$force) {
|
||||
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
||||
$bCronIsRunning = (boolean)($arrayCron["bCronIsRunning"]);
|
||||
$sLastExecution = $arrayCron["sLastExecution"];
|
||||
$processcTimeProcess = (isset($arrayCron["processcTimeProcess"]))? intval($arrayCron["processcTimeProcess"]) : 10; //Minutes
|
||||
$processcTimeStart = (isset($arrayCron["processcTimeStart"]))? $arrayCron["processcTimeStart"] : 0;
|
||||
} else {
|
||||
G::rm_dir(PATH_DATA . "cron");
|
||||
}
|
||||
}
|
||||
if ($bCronIsRunning && $processcTimeStart != 0) {
|
||||
if ((time() - $processcTimeStart) > ($processcTimeProcess * 60)) {
|
||||
//Cron finished his execution for some reason
|
||||
$bCronIsRunning = false;
|
||||
|
||||
$force = false;
|
||||
$osIsLinux = strtoupper(substr(PHP_OS, 0, 3)) != "WIN";
|
||||
|
||||
for ($i = 1; $i <= count($argv) - 1; $i++) {
|
||||
if (strpos($argv[$i], "+force") !== false) {
|
||||
$force = true;
|
||||
unset($argv[$i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$bCronIsRunning) {
|
||||
if (!$force && file_exists(PATH_DATA . "cron")) {
|
||||
//Windows flag
|
||||
//Get data of cron file
|
||||
$arrayCron = unserialize(trim(file_get_contents(PATH_DATA . "cron")));
|
||||
|
||||
$bCronIsRunning = (boolean)($arrayCron["bCronIsRunning"]);
|
||||
$sLastExecution = $arrayCron["sLastExecution"];
|
||||
$processcTimeProcess = (isset($arrayCron["processcTimeProcess"]))? (int)($arrayCron["processcTimeProcess"]) : 10; //Minutes
|
||||
$processcTimeStart = (isset($arrayCron["processcTimeStart"]))? $arrayCron["processcTimeStart"] : 0;
|
||||
}
|
||||
|
||||
if (!$force && $osIsLinux) {
|
||||
//Linux flag
|
||||
//Check if cron it's running
|
||||
exec("ps -fea | grep cron.php | grep -v grep", $arrayOutput);
|
||||
|
||||
if (count($arrayOutput) > 1) {
|
||||
$bCronIsRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
//if (!$force && $bCronIsRunning && $processcTimeStart != 0) {
|
||||
// if ((time() - $processcTimeStart) > ($processcTimeProcess * 60)) {
|
||||
// //Cron finished his execution for some reason
|
||||
// $bCronIsRunning = false;
|
||||
// }
|
||||
//}
|
||||
|
||||
if ($force || !$bCronIsRunning) {
|
||||
//Start cron
|
||||
$arrayCron = array("bCronIsRunning" => "1", "sLastExecution" => date("Y-m-d H:i:s"));
|
||||
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2012 Colosa Inc.23
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
*
|
||||
* For more information, contact Colosa Inc, 5304 Ventura Drive,
|
||||
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// check script parameters
|
||||
@@ -28,18 +28,18 @@
|
||||
//(count ($argv) == 4) || ((count ($argv) == 5) && ($argv [3] != '-skip'))
|
||||
$commandLineSyntaxMsg = "Invalid command line arguments: \n " .
|
||||
"syntax: ".
|
||||
"php reindex_solr.php [workspace_name] [reindexall|reindexmissing|optimizeindex|reindexone] [-skip {record_number}] [-reindextrunksize {trunk_size}] [-appuid {APP_UID}]\n" .
|
||||
"php reindex_solr.php [workspace_name] [reindexall|reindexmissing|optimizeindex|reindexone] [-skip {record_number}] [-reindextrunksize {trunk_size}] [-appuid {APP_UID}]\n" .
|
||||
" Where \n".
|
||||
" reindexall : reindex all the database. \n" .
|
||||
" reindexall : reindex all the database. \n" .
|
||||
" reindexmissing: reindex only the missing records stored in database. \n".
|
||||
" (records defined in APP_SOLR_QUEUE table are required)\n" .
|
||||
" optimizeindex: optimize the changes in the search index. (used to get faster results) \n" .
|
||||
" Optional Options: \n" .
|
||||
" -skip {record_number}: used to skip a number of records. \n ex: -skip 10000 //skips the first 10000 records. \n" .
|
||||
" -reindextrunksize {trunk_size}: specify the number of records sent to index each time. \n ex: -reindextrunksize 100 //(default = 1000) \n Reduce the trunk if using big documents, and memory is not enough. \n";
|
||||
" -reindextrunksize {trunk_size}: specify the number of records sent to index each time. \n ex: -reindextrunksize 100 //(default = 1000) \n Reduce the trunk if using big documents, and memory is not enough. \n";
|
||||
|
||||
if ( (count ($argv) < 3) || ((count ($argv) % 2) == 0) ||
|
||||
($argv [2] != 'reindexall' && $argv [2] != 'reindexmissing' && $argv [2] != 'optimizeindex' && $argv [2] != 'reindexone')) {
|
||||
if ( (count ($argv) < 3) || ((count ($argv) % 2) == 0) ||
|
||||
($argv [2] != 'reindexall' && $argv [2] != 'reindexmissing' && $argv [2] != 'optimizeindex' && $argv [2] != 'reindexone')) {
|
||||
print $commandLineSyntaxMsg;
|
||||
die ();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ if(count ($argv) > 3) {
|
||||
if($argv [$argNumber] == '-appuid') {
|
||||
//use skip option
|
||||
$appUid = $argv [$argNumber + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
print $commandLineSyntaxMsg;
|
||||
@@ -106,7 +106,7 @@ if (! defined ('PATH_HOME')) {
|
||||
array_pop ($docuroot);
|
||||
$pathOutTrunk = implode (PATH_SEP, $docuroot) . PATH_SEP;
|
||||
// to do: check previous algorith for Windows $pathTrunk = "c:/home/";
|
||||
|
||||
|
||||
define ('PATH_HOME', $pathhome);
|
||||
define ('PATH_TRUNK', $pathTrunk);
|
||||
define ('PATH_OUTTRUNK', $pathOutTrunk);
|
||||
@@ -176,20 +176,6 @@ if (! defined ('PATH_HOME')) {
|
||||
|
||||
// G::loadClass('pmScript');
|
||||
|
||||
// //default values
|
||||
// $bCronIsRunning = false;
|
||||
// $sLastExecution = '';
|
||||
// if ( file_exists(PATH_DATA . 'cron') ) {
|
||||
// $aAux = unserialize( trim( @file_get_contents(PATH_DATA . 'cron')) );
|
||||
// $bCronIsRunning = (boolean)$aAux['bCronIsRunning'];
|
||||
// $sLastExecution = $aAux['sLastExecution'];
|
||||
// }
|
||||
// else {
|
||||
// //if not exists the file, just create a new one with current date
|
||||
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
|
||||
// '1', 'sLastExecution' => date('Y-m-d H:i:s'))));
|
||||
// }
|
||||
|
||||
print "PATH_HOME: " . PATH_HOME . "\n";
|
||||
print "PATH_DB: " . PATH_DB . "\n";
|
||||
print "PATH_CORE: " . PATH_CORE . "\n";
|
||||
@@ -199,19 +185,19 @@ if (! defined ('SYS_SYS')) {
|
||||
$sObject = $workspaceName;
|
||||
$sNow = ''; // $argv[2];
|
||||
$sFilter = '';
|
||||
|
||||
|
||||
for ($i = 3; $i < count ($argv); $i++) {
|
||||
$sFilter .= ' ' . $argv [$i];
|
||||
}
|
||||
|
||||
|
||||
$oDirectory = dir (PATH_DB);
|
||||
|
||||
|
||||
if (is_dir (PATH_DB . $sObject)) {
|
||||
saveLog ('main', 'action', "checking folder " . PATH_DB . $sObject);
|
||||
if (file_exists (PATH_DB . $sObject . PATH_SEP . 'db.php')) {
|
||||
|
||||
|
||||
define ('SYS_SYS', $sObject);
|
||||
|
||||
|
||||
// ****************************************
|
||||
// read initialize file
|
||||
require_once PATH_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.system.php';
|
||||
@@ -219,16 +205,16 @@ if (! defined ('SYS_SYS')) {
|
||||
define ('MEMCACHED_ENABLED', $config ['memcached']);
|
||||
define ('MEMCACHED_SERVER', $config ['memcached_server']);
|
||||
define ('TIME_ZONE', $config ['time_zone']);
|
||||
|
||||
|
||||
date_default_timezone_set (TIME_ZONE);
|
||||
print "TIME_ZONE: " . TIME_ZONE . "\n";
|
||||
print "MEMCACHED_ENABLED: " . MEMCACHED_ENABLED . "\n";
|
||||
print "MEMCACHED_SERVER: " . MEMCACHED_SERVER . "\n";
|
||||
// ****************************************
|
||||
|
||||
|
||||
include_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths_installed.php');
|
||||
include_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
|
||||
|
||||
|
||||
// ***************** PM Paths DATA **************************
|
||||
define ('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
|
||||
define ('PATH_DOCUMENT', PATH_DATA_SITE . 'files/');
|
||||
@@ -238,7 +224,7 @@ if (! defined ('SYS_SYS')) {
|
||||
define ('PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/');
|
||||
define ('PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles' . PATH_SEP);
|
||||
define ('PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies' . PATH_SEP);
|
||||
|
||||
|
||||
// server info file
|
||||
if (is_file (PATH_DATA_SITE . PATH_SEP . '.server_info')) {
|
||||
$SERVER_INFO = file_get_contents (PATH_DATA_SITE . PATH_SEP . '.server_info');
|
||||
@@ -250,10 +236,10 @@ if (! defined ('SYS_SYS')) {
|
||||
else {
|
||||
eprintln ("WARNING! No server info found!", 'red');
|
||||
}
|
||||
|
||||
|
||||
// read db configuration
|
||||
$sContent = file_get_contents (PATH_DB . $sObject . PATH_SEP . 'db.php');
|
||||
|
||||
|
||||
$sContent = str_replace ('<?php', '', $sContent);
|
||||
$sContent = str_replace ('<?', '', $sContent);
|
||||
$sContent = str_replace ('?>', '', $sContent);
|
||||
@@ -261,7 +247,7 @@ if (! defined ('SYS_SYS')) {
|
||||
$sContent = str_replace ("('", "$", $sContent);
|
||||
$sContent = str_replace ("',", '=', $sContent);
|
||||
$sContent = str_replace (");", ';', $sContent);
|
||||
|
||||
|
||||
eval ($sContent);
|
||||
$dsn = $DB_ADAPTER . '://' . $DB_USER . ':' . $DB_PASS . '@' . $DB_HOST . '/' . $DB_NAME;
|
||||
$dsnRbac = $DB_ADAPTER . '://' . $DB_RBAC_USER . ':' . $DB_RBAC_PASS . '@' . $DB_RBAC_HOST . '/' . $DB_RBAC_NAME;
|
||||
@@ -293,7 +279,7 @@ if (! defined ('SYS_SYS')) {
|
||||
fclose ($oFile);
|
||||
Propel::init (PATH_CORE . 'config/_databases_.php');
|
||||
// Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
|
||||
|
||||
|
||||
eprintln ("Processing workspace: " . $sObject, 'green');
|
||||
try {
|
||||
processWorkspace ();
|
||||
@@ -312,10 +298,6 @@ else {
|
||||
processWorkspace ();
|
||||
}
|
||||
|
||||
// finally update the file
|
||||
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
|
||||
// '0', 'sLastExecution' => date('Y-m-d H:i:s'))));
|
||||
|
||||
function processWorkspace()
|
||||
{
|
||||
global $sLastExecution;
|
||||
@@ -323,16 +305,16 @@ function processWorkspace()
|
||||
global $SkipRecords;
|
||||
global $TrunkSize;
|
||||
global $appUid;
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
if (($solrConf = System::solrEnv (SYS_SYS)) !== false) {
|
||||
G::LoadClass ('AppSolr');
|
||||
print "Solr Configuration file: " . PATH_DATA_SITE . "env.ini\n";
|
||||
print "solr_enabled: " . $solrConf ['solr_enabled'] . "\n";
|
||||
print "solr_host: " . $solrConf ['solr_host'] . "\n";
|
||||
print "solr_instance: " . $solrConf ['solr_instance'] . "\n";
|
||||
|
||||
|
||||
$oAppSolr = new AppSolr ($solrConf ['solr_enabled'], $solrConf ['solr_host'], $solrConf ['solr_instance']);
|
||||
if ($ScriptAction == "reindexall") {
|
||||
$oAppSolr->reindexAllApplications ($SkipRecords, $TrunkSize);
|
||||
@@ -353,7 +335,7 @@ function processWorkspace()
|
||||
else {
|
||||
print "Incomplete Solr configuration. See configuration file: " . PATH_DATA_SITE . "env.ini";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
saveLog ("main", "error", "Error processing workspace : " . $oError->getMessage () . "\n");
|
||||
@@ -366,7 +348,7 @@ function saveLog($sSource, $sType, $sDescription)
|
||||
global $isDebug;
|
||||
if ($isDebug)
|
||||
print date ('H:i:s') . " ($sSource) $sType $sDescription <br>\n";
|
||||
|
||||
|
||||
G::verifyPath (PATH_DATA . 'log' . PATH_SEP, true);
|
||||
$message = '(' . $sSource . ') ' . $sDescription . "\n";
|
||||
if ($sType == 'action') {
|
||||
@@ -386,7 +368,7 @@ function setExecutionMessage($m)
|
||||
$len = strlen ($m);
|
||||
$linesize = 60;
|
||||
$rOffset = $linesize - $len;
|
||||
|
||||
|
||||
eprint ("* $m");
|
||||
for ($i = 0; $i < $rOffset; $i++)
|
||||
eprint ('.');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2012 Colosa Inc.23
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
*
|
||||
* For more information, contact Colosa Inc, 5304 Ventura Drive,
|
||||
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// check script parameters
|
||||
@@ -29,13 +29,13 @@
|
||||
$commandLineSyntaxMsg = "Invalid command line arguments: \n " .
|
||||
"Verify the list of cases comparing db vs solr lists by user if usr_uid is specify only verify one user otherwhise all users ".
|
||||
"syntax: ".
|
||||
"php verify_solr.php [workspace_name] [-usruid {USR_UID}]\n" .
|
||||
"php verify_solr.php [workspace_name] [-usruid {USR_UID}]\n" .
|
||||
" Where \n".
|
||||
" workspace_name : is the workspace that is being verified. \n" .
|
||||
" workspace_name : is the workspace that is being verified. \n" .
|
||||
" Optional Options: \n" .
|
||||
" -usruid {USR_UID}: verify only one user with the specified user uid. \n ";
|
||||
" -usruid {USR_UID}: verify only one user with the specified user uid. \n ";
|
||||
|
||||
if ( (count ($argv) < 2) || ((count ($argv) > 2) && ((count ($argv) % 2) != 0))) {
|
||||
if ( (count ($argv) < 2) || ((count ($argv) > 2) && ((count ($argv) % 2) != 0))) {
|
||||
print $commandLineSyntaxMsg;
|
||||
die ();
|
||||
}
|
||||
@@ -43,7 +43,7 @@ $workspaceName = $argv [1];
|
||||
$usrUid = "";
|
||||
|
||||
if((count ($argv) > 2)){
|
||||
$usrUid = $argv [3];
|
||||
$usrUid = $argv [3];
|
||||
}
|
||||
|
||||
ini_set ('display_errors', 1);
|
||||
@@ -70,13 +70,13 @@ if (! defined ('PATH_HOME')) {
|
||||
array_pop ($docuroot);
|
||||
$pathOutTrunk = implode (PATH_SEP, $docuroot) . PATH_SEP;
|
||||
// to do: check previous algorith for Windows $pathTrunk = "c:/home/";
|
||||
|
||||
|
||||
define ('PATH_HOME', $pathhome);
|
||||
define ('PATH_TRUNK', $pathTrunk);
|
||||
define ('PATH_OUTTRUNK', $pathOutTrunk);
|
||||
|
||||
|
||||
require_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
|
||||
|
||||
|
||||
G::LoadThirdParty ('pear/json', 'class.json');
|
||||
G::LoadThirdParty ('smarty/libs', 'Smarty.class');
|
||||
G::LoadSystem ('error');
|
||||
@@ -107,20 +107,6 @@ require_once 'classes/model/AppEvent.php';
|
||||
require_once 'classes/model/CaseScheduler.php';
|
||||
// G::loadClass('pmScript');
|
||||
|
||||
// //default values
|
||||
// $bCronIsRunning = false;
|
||||
// $sLastExecution = '';
|
||||
// if ( file_exists(PATH_DATA . 'cron') ) {
|
||||
// $aAux = unserialize( trim( @file_get_contents(PATH_DATA . 'cron')) );
|
||||
// $bCronIsRunning = (boolean)$aAux['bCronIsRunning'];
|
||||
// $sLastExecution = $aAux['sLastExecution'];
|
||||
// }
|
||||
// else {
|
||||
// //if not exists the file, just create a new one with current date
|
||||
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
|
||||
// '1', 'sLastExecution' => date('Y-m-d H:i:s'))));
|
||||
// }
|
||||
|
||||
print "PATH_HOME: " . PATH_HOME . "\n";
|
||||
print "PATH_DB: " . PATH_DB . "\n";
|
||||
print "PATH_CORE: " . PATH_CORE . "\n";
|
||||
@@ -131,19 +117,19 @@ if (! defined ('SYS_SYS')) {
|
||||
$sNow = ''; // $argv[2];
|
||||
/*
|
||||
$sFilter = '';
|
||||
|
||||
|
||||
for ($i = 3; $i < count ($argv); $i++) {
|
||||
$sFilter .= ' ' . $argv [$i];
|
||||
}*/
|
||||
|
||||
|
||||
$oDirectory = dir (PATH_DB);
|
||||
|
||||
|
||||
if (is_dir (PATH_DB . $sObject)) {
|
||||
saveLog ('main', 'action', "checking folder " . PATH_DB . $sObject);
|
||||
if (file_exists (PATH_DB . $sObject . PATH_SEP . 'db.php')) {
|
||||
|
||||
|
||||
define ('SYS_SYS', $sObject);
|
||||
|
||||
|
||||
// ****************************************
|
||||
// read initialize file
|
||||
require_once PATH_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.system.php';
|
||||
@@ -151,16 +137,16 @@ if (! defined ('SYS_SYS')) {
|
||||
define ('MEMCACHED_ENABLED', $config ['memcached']);
|
||||
define ('MEMCACHED_SERVER', $config ['memcached_server']);
|
||||
define ('TIME_ZONE', $config ['time_zone']);
|
||||
|
||||
|
||||
date_default_timezone_set (TIME_ZONE);
|
||||
print "TIME_ZONE: " . TIME_ZONE . "\n";
|
||||
print "MEMCACHED_ENABLED: " . MEMCACHED_ENABLED . "\n";
|
||||
print "MEMCACHED_SERVER: " . MEMCACHED_SERVER . "\n";
|
||||
// ****************************************
|
||||
|
||||
|
||||
include_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths_installed.php');
|
||||
include_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
|
||||
|
||||
|
||||
// ***************** PM Paths DATA **************************
|
||||
define ('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
|
||||
define ('PATH_DOCUMENT', PATH_DATA_SITE . 'files/');
|
||||
@@ -170,7 +156,7 @@ if (! defined ('SYS_SYS')) {
|
||||
define ('PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/');
|
||||
define ('PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles' . PATH_SEP);
|
||||
define ('PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies' . PATH_SEP);
|
||||
|
||||
|
||||
// server info file
|
||||
if (is_file (PATH_DATA_SITE . PATH_SEP . '.server_info')) {
|
||||
$SERVER_INFO = file_get_contents (PATH_DATA_SITE . PATH_SEP . '.server_info');
|
||||
@@ -182,10 +168,10 @@ if (! defined ('SYS_SYS')) {
|
||||
else {
|
||||
eprintln ("WARNING! No server info found!", 'red');
|
||||
}
|
||||
|
||||
|
||||
// read db configuration
|
||||
$sContent = file_get_contents (PATH_DB . $sObject . PATH_SEP . 'db.php');
|
||||
|
||||
|
||||
$sContent = str_replace ('<?php', '', $sContent);
|
||||
$sContent = str_replace ('<?', '', $sContent);
|
||||
$sContent = str_replace ('?>', '', $sContent);
|
||||
@@ -193,7 +179,7 @@ if (! defined ('SYS_SYS')) {
|
||||
$sContent = str_replace ("('", "$", $sContent);
|
||||
$sContent = str_replace ("',", '=', $sContent);
|
||||
$sContent = str_replace (");", ';', $sContent);
|
||||
|
||||
|
||||
eval ($sContent);
|
||||
$dsn = $DB_ADAPTER . '://' . $DB_USER . ':' . $DB_PASS . '@' . $DB_HOST . '/' . $DB_NAME;
|
||||
$dsnRbac = $DB_ADAPTER . '://' . $DB_RBAC_USER . ':' . $DB_RBAC_PASS . '@' . $DB_RBAC_HOST . '/' . $DB_RBAC_NAME;
|
||||
@@ -225,7 +211,7 @@ if (! defined ('SYS_SYS')) {
|
||||
fclose ($oFile);
|
||||
Propel::init (PATH_CORE . 'config/_databases_.php');
|
||||
// Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
|
||||
|
||||
|
||||
eprintln ("Processing workspace: " . $sObject, 'green');
|
||||
try {
|
||||
processWorkspace ();
|
||||
@@ -244,10 +230,6 @@ else {
|
||||
processWorkspace ();
|
||||
}
|
||||
|
||||
// finally update the file
|
||||
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
|
||||
// '0', 'sLastExecution' => date('Y-m-d H:i:s'))));
|
||||
|
||||
function processWorkspace()
|
||||
{
|
||||
global $sLastExecution;
|
||||
@@ -255,11 +237,11 @@ function processWorkspace()
|
||||
//global $SkipRecords;
|
||||
//global $TrunkSize;
|
||||
global $usrUid;
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
//if $usrUid is not set get all the users
|
||||
|
||||
|
||||
//verify inbox
|
||||
verifyInboxList($usrUid);
|
||||
|
||||
@@ -351,10 +333,10 @@ function displayMissingCases($aAppUidsDB, $aAppUidsSolr)
|
||||
foreach($casesInDBNotSolr as $caseDB){
|
||||
print " ". $caseDB . " \n";
|
||||
}
|
||||
print " Cases in Solr but not in DB: \n";
|
||||
print " Cases in Solr but not in DB: \n";
|
||||
foreach($casesInSolrNotDB as $caseSolr){
|
||||
print " ". $caseSolr . " \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getListUids($usrUid, $action)
|
||||
@@ -365,21 +347,21 @@ function getListUids($usrUid, $action)
|
||||
print "solr_enabled: " . $solrConf ['solr_enabled'] . "\n";
|
||||
print "solr_host: " . $solrConf ['solr_host'] . "\n";
|
||||
print "solr_instance: " . $solrConf ['solr_instance'] . "\n";
|
||||
|
||||
|
||||
$oAppSolr = new AppSolr ($solrConf ['solr_enabled'], $solrConf ['solr_host'], $solrConf ['solr_instance']);
|
||||
|
||||
G::LoadClass("applications");
|
||||
$apps = new Applications();
|
||||
}
|
||||
else {
|
||||
print "Incomplete Solr configuration. See configuration file: " . PATH_DATA_SITE . "env.ini";
|
||||
print "Incomplete Solr configuration. See configuration file: " . PATH_DATA_SITE . "env.ini";
|
||||
return;
|
||||
}
|
||||
}
|
||||
//get the list of id's
|
||||
$userUid = $usrUid;
|
||||
$start = 0;
|
||||
$limit = 1;
|
||||
$action = $action; //todo,
|
||||
$action = $action; //todo,
|
||||
$filter = '';
|
||||
$search = '';
|
||||
$process = '';
|
||||
@@ -392,7 +374,7 @@ function getListUids($usrUid, $action)
|
||||
$dir = 'DESC';
|
||||
$sort = 'APP_NUMBER';
|
||||
$category = '';
|
||||
|
||||
|
||||
$dataSolr = $oAppSolr->getAppGridData(
|
||||
$userUid,
|
||||
$start,
|
||||
@@ -411,7 +393,7 @@ function getListUids($usrUid, $action)
|
||||
$sort
|
||||
);
|
||||
|
||||
|
||||
|
||||
$dataDB = $apps->getAll(
|
||||
$userUid,
|
||||
$start,
|
||||
@@ -443,7 +425,7 @@ function getListUids($usrUid, $action)
|
||||
$start = $i * $trunkSize;
|
||||
$limit = $trunkSize;
|
||||
//print " Loop $start to " . (String)($start + $trunkSize) . " \n";
|
||||
|
||||
|
||||
$dataDB = $apps->getAll(
|
||||
$userUid,
|
||||
$start,
|
||||
@@ -461,7 +443,7 @@ function getListUids($usrUid, $action)
|
||||
$dir,
|
||||
$sort,
|
||||
$category
|
||||
);
|
||||
);
|
||||
foreach($dataDB["data"] as $caseDB){
|
||||
$aAppUidsDB[] = $caseDB["APP_UID"];
|
||||
}
|
||||
@@ -475,7 +457,7 @@ function getListUids($usrUid, $action)
|
||||
$start = $i * $trunkSize;
|
||||
$limit = $trunkSize;
|
||||
//print " Loop $start to " . (String)($start + $trunkSize) . " \n";
|
||||
|
||||
|
||||
$dataSolr = $oAppSolr->getAppGridData(
|
||||
$userUid,
|
||||
$start,
|
||||
@@ -515,7 +497,7 @@ function saveLog($sSource, $sType, $sDescription)
|
||||
global $isDebug;
|
||||
if ($isDebug)
|
||||
print date ('H:i:s') . " ($sSource) $sType $sDescription <br>\n";
|
||||
|
||||
|
||||
G::verifyPath (PATH_DATA . 'log' . PATH_SEP, true);
|
||||
$message = '(' . $sSource . ') ' . $sDescription . "\n";
|
||||
if ($sType == 'action') {
|
||||
@@ -535,7 +517,7 @@ function setExecutionMessage($m)
|
||||
$len = strlen ($m);
|
||||
$linesize = 60;
|
||||
$rOffset = $linesize - $len;
|
||||
|
||||
|
||||
eprint ("* $m");
|
||||
for ($i = 0; $i < $rOffset; $i++)
|
||||
eprint ('.');
|
||||
|
||||
@@ -14,23 +14,38 @@ if ($RBAC->userCanAccess("PM_SETUP") != 1) {
|
||||
$bCronIsRunning = false;
|
||||
$sLastExecution = null;
|
||||
$processcTimeProcess = 0;
|
||||
$processcTimeStart = 0;
|
||||
$processcTimeStart = 0;
|
||||
|
||||
if (file_exists( PATH_DATA . "cron" )) {
|
||||
$arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) );
|
||||
$bCronIsRunning = (boolean) ($arrayCron["bCronIsRunning"]);
|
||||
$osIsLinux = strtoupper(substr(PHP_OS, 0, 3)) != "WIN";
|
||||
|
||||
if (file_exists(PATH_DATA . "cron")) {
|
||||
//Windows flag
|
||||
//Get data of cron file
|
||||
$arrayCron = unserialize(trim(file_get_contents(PATH_DATA . "cron")));
|
||||
|
||||
$bCronIsRunning = (boolean)($arrayCron["bCronIsRunning"]);
|
||||
$sLastExecution = $arrayCron["sLastExecution"];
|
||||
$processcTimeProcess = (isset( $arrayCron["processcTimeProcess"] )) ? intval( $arrayCron["processcTimeProcess"] ) : 10;
|
||||
$processcTimeStart = (isset( $arrayCron["processcTimeStart"] )) ? $arrayCron["processcTimeStart"] : 0;
|
||||
$processcTimeProcess = (isset($arrayCron["processcTimeProcess"]))? (int)($arrayCron["processcTimeProcess"]) : 10; //Minutes
|
||||
$processcTimeStart = (isset($arrayCron["processcTimeStart"]))? $arrayCron["processcTimeStart"] : 0;
|
||||
}
|
||||
|
||||
if ($bCronIsRunning && $processcTimeStart != 0) {
|
||||
if ((time() - $processcTimeStart) > ($processcTimeProcess * 60)) {
|
||||
//Cron finished his execution for some reason
|
||||
$bCronIsRunning = false;
|
||||
if ($osIsLinux) {
|
||||
//Linux flag
|
||||
//Check if cron it's running
|
||||
exec("ps -fea | grep cron.php | grep -v grep", $arrayOutput);
|
||||
|
||||
if (count($arrayOutput) > 0) {
|
||||
$bCronIsRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
//if ($bCronIsRunning && $processcTimeStart != 0) {
|
||||
// if ((time() - $processcTimeStart) > ($processcTimeProcess * 60)) {
|
||||
// //Cron finished his execution for some reason
|
||||
// $bCronIsRunning = false;
|
||||
// }
|
||||
//}
|
||||
|
||||
//Data
|
||||
$c = new Configurations();
|
||||
$configPage = $c->getConfiguration( "cronList", "pageSize", null, $_SESSION["USER_LOGGED"] );
|
||||
|
||||
Reference in New Issue
Block a user