From: Michael Vogel Date: Sun, 13 Sep 2015 17:08:10 +0000 (+0200) Subject: Pumpio: Start the syncronisation as a forked process to avoid stale connections X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b2508c127f002c3fc7ce6141eeb0d0ef70e57efb;p=friendica-addons.git Pumpio: Start the syncronisation as a forked process to avoid stale connections --- diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index dc4a6a42..95bc6b9f 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -603,8 +603,7 @@ function pumpio_action(&$a, $uid, $uri, $action, $content = "") { } } - -function pumpio_cron(&$a,$b) { +function pumpio_sync(&$a) { $last = get_config('pumpio','last_poll'); $poll_interval = intval(get_config('pumpio','poll_interval')); @@ -667,6 +666,11 @@ function pumpio_cron(&$a,$b) { set_config('pumpio','last_poll', time()); } +function pumpio_cron(&$a,$b) { + //pumpio_sync($a); + proc_run("php","addon/pumpio/pumpio_sync.php"); +} + function pumpio_fetchtimeline(&$a, $uid) { $ckey = get_pconfig($uid, 'pumpio', 'consumer_key'); $csecret = get_pconfig($uid, 'pumpio', 'consumer_secret'); diff --git a/pumpio/pumpio_sync.php b/pumpio/pumpio_sync.php new file mode 100644 index 00000000..346376fa --- /dev/null +++ b/pumpio/pumpio_sync.php @@ -0,0 +1,66 @@ + $maxsysload) { + logger('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.'); + return; + } + } + + $lockpath = get_lockpath(); + if ($lockpath != '') { + $pidfile = new pidfile($lockpath, 'pumpio_sync'); + if($pidfile->is_already_running()) { + logger("Already running"); + if ($pidfile->running_time() > 9*60) { + $pidfile->kill(); + logger("killed stale process"); + // Calling a new instance + proc_run('php','addon/pumpio/pumpio_sync.php'); + } + exit; + } + } + + pumpio_sync($a); +} + +if (array_search(__file__,get_included_files())===0){ + pumpio_sync_run($_SERVER["argv"],$_SERVER["argc"]); + killme(); +} +?>