5 if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
6 $directory = dirname($_SERVER["argv"][0]);
8 if (substr($directory, 0, 1) != "/")
9 $directory = $_SERVER["PWD"]."/".$directory;
11 $directory = realpath($directory."/..");
16 require_once("boot.php");
19 function pumpio_sync_run(&$argv, &$argc){
27 @include(".htconfig.php");
28 require_once("include/dba.php");
29 $db = new dba($db_host, $db_user, $db_pass, $db_data);
30 unset($db_host, $db_user, $db_pass, $db_data);
33 require_once("addon/pumpio/pumpio.php");
34 require_once("include/pidfile.php");
36 $maxsysload = intval(get_config('system','maxloadavg'));
39 if(function_exists('sys_getloadavg')) {
40 $load = sys_getloadavg();
41 if(intval($load[0]) > $maxsysload) {
42 logger('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.');
47 // This is deprecated with the worker
48 if (function_exists("get_lockpath")) {
49 $lockpath = get_lockpath();
50 if ($lockpath != '') {
51 $pidfile = new pidfile($lockpath, 'pumpio_sync');
52 if($pidfile->is_already_running()) {
53 logger("Already running");
54 if ($pidfile->running_time() > 9*60) {
56 logger("killed stale process");
57 // Calling a new instance
58 proc_run('php','addon/pumpio/pumpio_sync.php');
67 if (array_search(__file__,get_included_files())===0){
68 pumpio_sync_run($_SERVER["argv"],$_SERVER["argc"]);