Browse Source

Cron - enabled mode CLI

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1138 a333f486-631f-4898-b8df-5754b55c2be0
romainq 14 years ago
parent
commit
809227fc60
2 changed files with 29 additions and 3 deletions
  1. 1 1
      synchro/synchro_exec.php
  2. 28 2
      webservices/cron.php

+ 1 - 1
synchro/synchro_exec.php

@@ -50,7 +50,7 @@ function UsageAndExit($oP)
 	if ($bModeCLI)
 	if ($bModeCLI)
 	{
 	{
 		$oP->p("USAGE:\n");
 		$oP->p("USAGE:\n");
-		$oP->p("php -q synchro_exec.php auth_user=<login> auth_pwd=<password> data_sources=<comma_separated_list_of_data_sources>\n");		
+		$oP->p("php -q synchro_exec.php --auth_user=<login> --auth_pwd=<password> --data_sources=<comma_separated_list_of_data_sources>\n");		
 	}
 	}
 	else
 	else
 	{
 	{

+ 28 - 2
webservices/cron.php

@@ -31,10 +31,36 @@ require_once(APPROOT.'/application/clipage.class.inc.php');
 require_once(APPROOT.'/application/startup.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);
+}
 
 
-// Known limitation - the background process periodicity is NOT taken into account
+function UsageAndExit($oP)
+{
+	$bModeCLI = utils::IsModeCLI();
+
+	if ($bModeCLI)
+	{
+		$oP->p("USAGE:\n");
+		$oP->p("php -q cron.php --auth_user=<login> --auth_pwd=<password> [--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)
 function CronExec($oP, $aBackgroundProcesses, $bVerbose)
 {
 {
 	$iStarted = time();
 	$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)
 if ($bVerbose)
 {
 {