2 if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
3 $directory = dirname($_SERVER["argv"][0]);
5 if (substr($directory, 0, 1) != "/")
6 $directory = $_SERVER["PWD"]."/".$directory;
8 $directory = realpath($directory."/..");
13 require_once("boot.php");
16 function pumpio_sync_run(&$argv, &$argc){
24 @include(".htconfig.php");
25 require_once("include/dba.php");
26 $db = new dba($db_host, $db_user, $db_pass, $db_data);
27 unset($db_host, $db_user, $db_pass, $db_data);
30 require_once("addon/pumpio/pumpio.php");
31 require_once("include/pidfile.php");
33 $maxsysload = intval(get_config('system','maxloadavg'));
36 if(function_exists('sys_getloadavg')) {
37 $load = sys_getloadavg();
38 if(intval($load[0]) > $maxsysload) {
39 logger('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.');
44 $lockpath = get_lockpath();
45 if ($lockpath != '') {
46 $pidfile = new pidfile($lockpath, 'pumpio_sync');
47 if($pidfile->is_already_running()) {
48 logger("Already running");
49 if ($pidfile->running_time() > 9*60) {
51 logger("killed stale process");
52 // Calling a new instance
53 proc_run('php','addon/pumpio/pumpio_sync.php');
62 if (array_search(__file__,get_included_files())===0){
63 pumpio_sync_run($_SERVER["argv"],$_SERVER["argc"]);