2006-10-25 02:41:56 +00:00
< ?
2010-12-02 17:25:23 +00:00
require_once ( '../common.inc.functions.php' );
$logPath = get_logpath ();
2011-03-15 20:28:10 +00:00
// Check which OS we are running
$pos = strpos ( getcwd (), '/' );
if ( $pos === false )
{
// Windows os server.
// if IIS Web Server use WScript.Shell 'run' command and.. we need a batch file to start a process and return immediately
$bat_filename = " ../data/judges_sa.bat " ;
if ( file_exists ( $bat_filename )){
// delete the batch file then re-create it with the current date
unlink ( $bat_filename );
}
$bat_file = fopen ( $bat_filename , " w " );
if ( $bat_file ) {
fwrite ( $bat_file , " ECHO OFF " . " \n " );
fwrite ( $bat_file , " START /BELOWNORMAL /B php judges_sa.php > $logPath /judge_scheduler_ " . date ( " YmdHis " ) . " .log 2>&1 & " . " \n " );
fwrite ( $bat_file , " EXIT " . " \n " );
fclose ( $bat_file );
}
$WshShell = new COM ( " WScript.Shell " );
// next line designed for Windows os with IIS web server. It will probably fail if Windows using apache web server
try {
$oExec = $WshShell -> run ( $bat_filename , 0 , false ); // THIS SHOULD WORK for windows using IIS as webserver.
}
catch ( Exception $e ) {
// if the wshshell-> run fails then we are perhaps running an apache server and the next might work.
// But, the call in judges_sa_launcher_apache.php does not return until completed so I use this logic
// to inform the user how to get to the status page.
// CAUTION: This path REQUIRES that php be compiled with CLI option and other things Dennis does not understand!
// This may work for some servers. NEVER use this on a shared server - you will hog it and get your account suspended.
echo " This server requires manual intervention to start the scheduler and to navigate to the Status page.<br/> " ;
echo " The scheduler will run at normal priority - which in some servers may present a sluggish response.<br /> " ;
echo " Please follow these instruction exactly:<br /> " ;
echo " 1. Click 'Start the Scheduler' link ONCE. (You will not see any change in this screen) <br /> " ;
echo " *** DO NOT Click 'Start the Scheduler' more than once!<br /> " ;
echo " 2. Click 'Check the Status' link and wait. (You will be taken to the Status Page. There, you should see that the scheduler is running.) <br /> " ;
echo " <br /><a href= \" judges_sa_launcher_apache.php \" >Start the Scheduler</a><br /><br /> " ;
echo " <a href= \" judges_scheduler_status.php \" >Check the Status</a><br /> " ;
exit ;
// This is the call that works - but it does not return until judges_sa is finished so... I launch it from another window
// exec("php judges_sa.php >$logPath/judge_scheduler_".date("YmdHis").".log 2>&1 &");
}
}
else {
// *nix server
2010-03-25 20:52:40 +00:00
//add PHP_SELF just so when we do a process listing on the server we know which fair its running for
//the argument does not get used by the script at all
2010-12-02 17:25:23 +00:00
exec ( " nice php judges_sa.php { $_SERVER [ 'PHP_SELF' ] } > $logPath /judge_scheduler_ " . date ( " YmdHis " ) . " .log 2>&1 & " );
2011-03-15 20:28:10 +00:00
}
2009-03-24 16:58:02 +00:00
usleep ( 1500000 ); // 1.5 second to allow the judges_sa to update the % status to 0% otherwise the status page will think its not running if it gets there too soon
2006-10-25 02:41:56 +00:00
header ( " Location: judges_scheduler_status.php " );
2007-05-10 19:18:01 +00:00
exit ;
2006-10-25 02:41:56 +00:00
?>