From 78396eafe3a462485e7c03f447d9f602ec32a821 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Mon, 21 Mar 2011 11:41:08 +0000 Subject: [PATCH] Cron - enabled mode CLI SVN:trunk[1138] --- synchro/synchro_exec.php | 2 +- webservices/cron.php | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/synchro/synchro_exec.php b/synchro/synchro_exec.php index f87d7abad..e9a1327f1 100644 --- a/synchro/synchro_exec.php +++ b/synchro/synchro_exec.php @@ -50,7 +50,7 @@ function UsageAndExit($oP) if ($bModeCLI) { $oP->p("USAGE:\n"); - $oP->p("php -q synchro_exec.php auth_user= auth_pwd= data_sources=\n"); + $oP->p("php -q synchro_exec.php --auth_user= --auth_pwd= --data_sources=\n"); } else { diff --git a/webservices/cron.php b/webservices/cron.php index 6317e827b..665298390 100644 --- a/webservices/cron.php +++ b/webservices/cron.php @@ -31,10 +31,36 @@ require_once(APPROOT.'/application/clipage.class.inc.php'); require_once(APPROOT.'/application/startup.inc.php'); +function ReadMandatoryParam($oP, $sParam) +{ + $sValue = utils::ReadParam($sParam, null, true /* Allow CLI */); + if (is_null($sValue)) + { + $oP->p("ERROR: Missing argument '$sParam'\n"); + UsageAndExit($oP); + } + return trim($sValue); +} + +function UsageAndExit($oP) +{ + $bModeCLI = utils::IsModeCLI(); + + if ($bModeCLI) + { + $oP->p("USAGE:\n"); + $oP->p("php -q cron.php --auth_user= --auth_pwd= [--verbose=1]\n"); + } + else + { + $oP->p("Optional parameter: verbose\n"); + } + $oP->output(); + exit -2; +} + // Known limitation - the background process periodicity is NOT taken into account - - function CronExec($oP, $aBackgroundProcesses, $bVerbose) { $iStarted = time(); @@ -126,7 +152,7 @@ foreach(get_declared_classes() as $sPHPClass) } -$bVerbose = utils::ReadParam('verbose', false); +$bVerbose = utils::ReadParam('verbose', false, true /* Allow CLI */); if ($bVerbose) {