From c431befd8e82db9b44d50118cf10dc2d88a5f15f Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 21 Jun 2017 12:03:06 +0000 Subject: [PATCH] There is only the worker left, so we can remove some old stuff --- pumpio/pumpio_sync.php | 61 +++------------------------------------- twitter/twitter.php | 18 +++--------- twitter/twitter_sync.php | 60 ++------------------------------------- 3 files changed, 11 insertions(+), 128 deletions(-) diff --git a/pumpio/pumpio_sync.php b/pumpio/pumpio_sync.php index 51efe9c4..a23eb4b0 100644 --- a/pumpio/pumpio_sync.php +++ b/pumpio/pumpio_sync.php @@ -1,71 +1,18 @@ $maxsysload) { + if (intval($load[0]) > Config::get('system', 'maxloadavg', 50)) { logger('system: load ' . $load[0] . ' too high. Pumpio sync deferred to next scheduled run.'); return; } } - // This is deprecated with the worker - if (function_exists("get_lockpath")) { - $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(); -} -?> diff --git a/twitter/twitter.php b/twitter/twitter.php index 19577b47..76b92ac8 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -621,16 +621,11 @@ function twitter_cron($a,$b) { } logger('twitter: cron_start'); - $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND()"); + $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'mirror_posts' AND `v` = '1'"); if(count($r)) { foreach($r as $rr) { logger('twitter: fetching for user '.$rr['uid']); - - if (get_config("system", "worker")) { - proc_run(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 1, $rr['uid']); - } else { - twitter_fetchtimeline($a, $rr['uid']); - } + proc_run(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 1, (int)$rr['uid']); } } @@ -640,7 +635,7 @@ function twitter_cron($a,$b) { $abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400); - $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()"); + $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1'"); if(count($r)) { foreach($r as $rr) { if ($abandon_days != 0) { @@ -652,12 +647,7 @@ function twitter_cron($a,$b) { } logger('twitter: importing timeline from user '.$rr['uid']); - - if (get_config("system", "worker")) { - proc_run(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 2, $rr['uid']); - } else { - twitter_fetchhometimeline($a, $rr["uid"]); - } + proc_run(PRIORITY_MEDIUM, "addon/twitter/twitter_sync.php", 2, (int)$rr['uid']); /* // To-Do // check for new contacts once a day diff --git a/twitter/twitter_sync.php b/twitter/twitter_sync.php index fd1915d8..ed9f3f85 100644 --- a/twitter/twitter_sync.php +++ b/twitter/twitter_sync.php @@ -1,45 +1,14 @@ $maxsysload) { + if (intval($load[0]) > Config::get('system', 'maxloadavg', 50)) { logger('system: load ' . $load[0] . ' too high. Twitter sync deferred to next scheduled run.'); return; } @@ -52,33 +21,10 @@ function twitter_sync_run($argv, $argc){ $mode = intval($argv[1]); $uid = intval($argv[2]); - // This is deprecated with the worker - if (function_exists("get_lockpath")) { - $lockpath = get_lockpath(); - if ($lockpath != '') { - $pidfile = new pidfile($lockpath, 'twitter_sync-'.$mode.'-'.$uid); - 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/twitter/twitter_sync.php', $mode, $uid); - } - exit; - } - } - } - if ($mode == 1) { twitter_fetchtimeline($a, $uid); } elseif ($mode == 2) { twitter_fetchhometimeline($a, $uid); } } - -if (array_search(__file__,get_included_files())===0){ - twitter_sync_run($_SERVER["argv"],$_SERVER["argc"]); - killme(); -} ?>