[Phphtmllib-devel] SF.net SVN: phphtmllib:[3298] trunk/open2300/bin/avi_daemon.php
Status: Beta
Brought to you by:
hemna
From: <he...@us...> - 2009-11-25 22:22:39
|
Revision: 3298 http://phphtmllib.svn.sourceforge.net/phphtmllib/?rev=3298&view=rev Author: hemna Date: 2009-11-25 22:22:29 +0000 (Wed, 25 Nov 2009) Log Message: ----------- added Added Paths: ----------- trunk/open2300/bin/avi_daemon.php Added: trunk/open2300/bin/avi_daemon.php =================================================================== --- trunk/open2300/bin/avi_daemon.php (rev 0) +++ trunk/open2300/bin/avi_daemon.php 2009-11-25 22:22:29 UTC (rev 3298) @@ -0,0 +1,153 @@ +#!/usr/local/bin/php +<?php +/** + * This script is used to update the open2300 + * website that runs on a different machine + * from the wx station. + * + * @package open2300 + */ + +$lib_path = realpath('../lib'); +ini_set('include_path', '.:/usr/local/lib:/usr/share/php/:'.$lib_path); + +define('PHPHTMLLIB', realpath('../lib/external/phphtmllib')); +$GLOBALS['path_base'] = realpath('..'); + +// autoload function for all our classes +require($GLOBALS['path_base'].'/lib/autoload.inc'); + +// setup error handling and required parameters +require($GLOBALS['path_base'].'/lib/init.inc'); + +$config->set('uncaught_exception_output', 'txt'); + +//other includes... +require_once('Console/Getargs.php'); + +//We have to process this stuff PRIOR to includes +//to properly set the MAC_ADDRESS and EMAILLABS_APP_TYPE env var. +/** + * The list of support command line options + */ +$arg_config = array('start' => array( + 'short' => 's', + 'min' => 0, + 'max' => 0, + 'desc' => 'Start the daemon. This is the default'), + 'kill' => array( + 'short' => 'k', + 'min' => 0, + 'max' => 0, + 'desc' => 'Gracefully kill/stop the daemon. Cleanup is done prior to exit. '. + 'If the daemon cron checker is still running, then the scheduler '. + 'daemon will get automatically restarted.'), + 'clean' => array( + 'short' => 'c', + 'min' => 0, + 'max' => 0, + 'desc' => 'Run Daemon cleanup. This nukes the db locks for this host. '. + 'This is automatically done internally when the daemon is '. + 'started or shut down'), + 'disable' => array( + 'short' => 'd', + 'min' => 0, + 'max' => 0, + 'desc' => 'Disable the daemon from starting. '. + 'This writes a file to disk, which start() looks for to enable '. + 'daemonizing'), + 'enable' => array( + 'short' => 'e', + 'min' => 0, + 'max' => 0, + 'desc' => 'Enable the daemon to be started. '. + 'This deletes the suppression file created by disable.'), +); + + +//command parser +$cmd =& Console_Getargs::factory($arg_config); +//qqq($args); +if ( PEAR::isError($cmd) ) { + if ( $cmd->getCode() === CONSOLE_GETARGS_ERROR_USER ) { + echo Console_Getargs::getHelp($arg_config, null, $cmd->getMessage())."\n"; + } else if ( $cmd->getCode() === CONSOLE_GETARGS_HELP ) { + echo Console_Getargs::getHelp($arg_config)."\n"; + } + exit; +} + +$start = $cmd->getValue('start'); +$kill = $cmd->getValue('kill'); +$clean = $cmd->getValue('clean'); +$enable = $cmd->getValue('enable'); +$disable = $cmd->getValue('disable'); + +function use_error() { + global $arg_config; + + echo "Only 1 command at a time\n\n"; + echo Console_Getargs::getHelp($arg_config)."\n"; + exit; +} + +//make sure we only have 1 command +if ($start) { + if ($kill || $clean || $enable || $disable) { + use_error(); + } + $command = 'start'; +} else if ($kill) { + if ($start || $clean || $enable || $disable) { + use_error(); + } + $command = 'kill'; +} else if ($clean) { + if ($start || $kill || $enable || $disable) { + use_error(); + } + $command = 'clean'; +} else if ($disable) { + if ($start || $kill || $enable || $clean) { + use_error(); + } + $command = 'disable'; +} else if ($enable) { + if ($start || $kill || $disable || $clean) { + use_error(); + } + $command = 'enable'; +} else { + $command = 'start'; +} + + +$daemon = new AviProcessorDaemon(); + +switch ($command) { + default: + case 'start': + echo "Starting Scheduler\n"; + try { + $daemon->start(); + } catch (Exception $e) { + if ($e->getCode() != DaemonException::ERR_ALREADY_RUNNING) { + throw $e; + } else { + echo $e->getMessage()."\n"; + } + + } + break; + + case 'kill': + case 'stop': + echo "Stopping Daemon\n"; + try { + $daemon->stop(); + } catch (Exception $e) { + echo $e->getMessage()."\n"; + } + break; +} +?> \ No newline at end of file Property changes on: trunk/open2300/bin/avi_daemon.php ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |