25 error_reporting(E_ALL);
34 print
"Usage: clearCronDeadlock.php SYSTEM_ROOT [--reset] [--force]\r\n\r\n";
37 if ((php_sapi_name() !=
'cli')) trigger_error(
"You can only run this script from the command line\n", E_USER_ERROR);
38 $SYSTEM_ROOT = (isset($_SERVER[
'argv'][1])) ? $_SERVER[
'argv'][1] :
'';
39 if (empty($SYSTEM_ROOT)) {
40 echo
"ERROR: You need to supply the path to the System Root as the first argument\n";
45 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.
'/core/include/init.inc')) {
46 echo
"ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
51 $RESET = (isset($_SERVER[
'argv'][2]) && $_SERVER[
'argv'][2] ==
'--reset') ?
true :
false;
52 $FORCE = (isset($_SERVER[
'argv'][3]) && $_SERVER[
'argv'][3] ==
'--force') ?
true :
false;
54 require_once $SYSTEM_ROOT.
'/core/include/init.inc';
56 $root_user=&$GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'root_user');
57 if (!$GLOBALS[
'SQ_SYSTEM']->setCurrentUser($root_user)) {
58 echo
"ERROR: Failed login in as root user\n";
62 $cronManager=&$GLOBALS[
'SQ_SYSTEM']->am->getSystemAsset(
'cron_manager');
63 $cronRunning=$cronManager->attr(
'running');
64 $cronRunCheck=(int)$cronManager->attr(
'run_check');
65 $cronWarnLimit=(int)$cronManager->attr(
'warn_after_num_run_checks');
66 $cr=($cronRunning) ?
'Yes' :
'No';
68 print
'Cron Running: ' . $cr .
', Run Checks: ' . $cronRunCheck .
'/' . $cronWarnLimit .
"\r\n";
70 if (($cronRunning && $cronRunCheck >= $cronWarnLimit) || $FORCE) {
71 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($cronManager->id,
'attributes');
72 $cronManager->setAttrValue(
'running', FALSE);
73 $cronManager->setAttrValue(
'run_check', 0);
74 $cronManager->saveAttributes();
75 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($cronManager->id,
'attributes');
77 echo
"Manual Reset Complete\r\n";
79 echo
"Deadlock Cleared\r\n";
82 echo
"No Deadlock Detected\r\n";
85 if ($cronRunning && $cronRunCheck >= $cronWarnLimit) {
86 echo
"Deadlock Detected\r\n";
88 echo
"No Deadlock Detected, To force manual reset use --reset --force\r\n";