]> git.mxchange.org Git - friendica.git/commitdiff
Now there is only the worker.
authorMichael <heluecht@pirati.ca>
Sun, 26 Feb 2017 23:16:49 +0000 (23:16 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 26 Feb 2017 23:16:49 +0000 (23:16 +0000)
25 files changed:
include/create_shadowentry.php
include/cron.php
include/cronhooks.php
include/cronjobs.php
include/dbclean.php
include/dbupdate.php
include/delivery.php
include/directory.php
include/discover_poco.php
include/expire.php
include/gprobe.php
include/notifier.php
include/onepoll.php
include/poller.php
include/pubsubpublish.php
include/queue.php
include/remove_contact.php
include/shadowupdate.php
include/spool_post.php
include/tagupdate.php
include/threadupdate.php
include/update_gcontact.php
mod/worker.php
view/templates/admin_site.tpl
view/templates/admin_summary.tpl

index 005295c97898b261dc820b0f1ad36177c65440eb..98db23f9effb1cd14aad0263d6e63941e359b07c 100644 (file)
@@ -6,26 +6,9 @@
  * This script is started from mod/item.php to save some time when doing a post.
  */
 
-use \Friendica\Core\Config;
-
-require_once("boot.php");
 require_once("include/threads.php");
 
 function create_shadowentry_run($argv, $argc) {
-       global $a, $db;
-
-       if (is_null($a))
-               $a = new App;
-
-       if (is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       }
-
-       Config::load();
-
        if ($argc != 2) {
                return;
        }
@@ -34,9 +17,4 @@ function create_shadowentry_run($argv, $argc) {
 
        add_shadow_entry($message_id);
 }
-
-if (array_search(__file__,get_included_files())===0){
-  create_shadowentry_run($_SERVER["argv"],$_SERVER["argc"]);
-  killme();
-}
 ?>
index 2fc8de51c5ebb25f61dde5820c67cc58ac6e9095..d2471c2bf7fb8f6effa076192f8ea82123088d3e 100644 (file)
@@ -1,35 +1,11 @@
 <?php
-if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
-       $directory = dirname($_SERVER["argv"][0]);
-
-       if (substr($directory, 0, 1) != "/")
-               $directory = $_SERVER["PWD"]."/".$directory;
-
-       $directory = realpath($directory."/..");
-
-       chdir($directory);
-}
-
 use \Friendica\Core\Config;
 
-require_once("boot.php");
 require_once("include/photos.php");
 require_once("include/user.php");
 
-
 function cron_run(&$argv, &$argc){
-       global $a, $db;
-
-       if(is_null($a)) {
-               $a = new App;
-       }
-
-       if(is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       };
+       global $a;
 
        require_once('include/session.php');
        require_once('include/datetime.php');
@@ -40,16 +16,6 @@ function cron_run(&$argv, &$argc){
        require_once('mod/nodeinfo.php');
        require_once('include/post_update.php');
 
-       Config::load();
-
-       // Don't check this stuff if the function is called by the poller
-       if (App::callstack() != "poller_run") {
-               if ($a->maxload_reached())
-                       return;
-               if (App::is_already_running('cron', 'include/cron.php', 540))
-                       return;
-       }
-
        $last = get_config('system','last_cron');
 
        $poll_interval = intval(get_config('system','cron_interval'));
@@ -64,10 +30,6 @@ function cron_run(&$argv, &$argc){
                }
        }
 
-       $a->set_baseurl(get_config('system','url'));
-
-       load_hooks();
-
        logger('cron: start');
 
        // run queue delivery process in the background
@@ -85,34 +47,17 @@ function cron_run(&$argv, &$argc){
        // Expire and remove user entries
        cron_expire_and_remove_users();
 
-       // If the worker is active, split the jobs in several sub processes
-       if (get_config("system", "worker")) {
-               // Check OStatus conversations
-               proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_mentions");
-
-               // Check every conversation
-               proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_conversations");
-
-               // Call possible post update functions
-               proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update");
-
-               // update nodeinfo data
-               proc_run(PRIORITY_LOW, "include/cronjobs.php", "nodeinfo");
-       } else {
-               // Check OStatus conversations
-               // Check only conversations with mentions (for a longer time)
-               ostatus::check_conversations(true);
+       // Check OStatus conversations
+       proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_mentions");
 
-               // Check every conversation
-               ostatus::check_conversations(false);
+       // Check every conversation
+       proc_run(PRIORITY_MEDIUM, "include/cronjobs.php", "ostatus_conversations");
 
-               // Call possible post update functions
-               // see include/post_update.php for more details
-               post_update();
+       // Call possible post update functions
+       proc_run(PRIORITY_LOW, "include/cronjobs.php", "post_update");
 
-               // update nodeinfo data
-               nodeinfo_cron();
-       }
+       // update nodeinfo data
+       proc_run(PRIORITY_LOW, "include/cronjobs.php", "nodeinfo");
 
        // once daily run birthday_updates and then expire in background
 
@@ -213,14 +158,6 @@ function cron_poll_contacts($argc, $argv) {
                $force     = true;
        }
 
-       $interval = intval(get_config('system','poll_interval'));
-       if (!$interval)
-               $interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval')));
-
-       // If we are using the worker we don't need a delivery interval
-       if (get_config("system", "worker"))
-               $interval = false;
-
        $sql_extra = (($manual_id) ? " AND `id` = $manual_id " : "");
 
        reload_plugins();
@@ -335,9 +272,6 @@ function cron_poll_contacts($argc, $argv) {
                        } else {
                                proc_run(PRIORITY_LOW, 'include/onepoll.php', $contact['id']);
                        }
-
-                       if($interval)
-                               @time_sleep_until(microtime(true) + (float) $interval);
                }
        }
 }
@@ -488,8 +422,3 @@ function cron_repair_database() {
        /// - remove children when parent got lost
        /// - set contact-id in item when not present
 }
-
-if (array_search(__file__,get_included_files())===0){
-       cron_run($_SERVER["argv"],$_SERVER["argc"]);
-       killme();
-}
index 72b86be427cc9f4dc034f5f64fb50aef5f4640a8..af5ab9f922cf4046554595e62d530345d730ca28 100644 (file)
@@ -2,37 +2,11 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
-
 function cronhooks_run(&$argv, &$argc){
-       global $a, $db;
-
-       if(is_null($a)) {
-               $a = new App;
-       }
-
-       if(is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       };
+       global $a;
 
-       require_once('include/session.php');
        require_once('include/datetime.php');
 
-       Config::load();
-
-       // Don't check this stuff if the function is called by the poller
-       if (App::callstack() != "poller_run") {
-               if ($a->maxload_reached())
-                       return;
-               if (App::is_already_running('cronhooks', 'include/cronhooks.php', 1140))
-                       return;
-       }
-
-       load_hooks();
-
        if (($argc == 2) AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
                 foreach ($a->hooks["cron"] as $hook)
                        if ($hook[1] == $argv[1]) {
@@ -62,13 +36,12 @@ function cronhooks_run(&$argv, &$argc){
 
        $d = datetime_convert();
 
-       if (get_config("system", "worker") AND is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
+       if (is_array($a->hooks) AND array_key_exists("cron", $a->hooks)) {
                 foreach ($a->hooks["cron"] as $hook) {
                        logger("Calling cronhooks for '".$hook[1]."'", LOGGER_DEBUG);
                        proc_run(PRIORITY_MEDIUM, "include/cronhooks.php", $hook[1]);
                }
-       } else
-               call_hooks('cron', $d);
+       }
 
        logger('cronhooks: end');
 
@@ -76,8 +49,3 @@ function cronhooks_run(&$argv, &$argc){
 
        return;
 }
-
-if (array_search(__file__,get_included_files())===0){
-       cronhooks_run($_SERVER["argv"],$_SERVER["argc"]);
-       killme();
-}
index f0a56370b81566dca314f50ab8e3164533b93f7d..5cc2bf1323518327a64c24d61d4373ead573bbf4 100644 (file)
@@ -1,44 +1,14 @@
 <?php
 use \Friendica\Core\Config;
 
-if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
-       $directory = dirname($_SERVER["argv"][0]);
-
-       if (substr($directory, 0, 1) != "/")
-               $directory = $_SERVER["PWD"]."/".$directory;
-
-       $directory = realpath($directory."/..");
-
-       chdir($directory);
-}
-
-require_once("boot.php");
-
-
 function cronjobs_run(&$argv, &$argc){
-       global $a, $db;
+       global $a;
 
-       if(is_null($a)) {
-               $a = new App;
-       }
-
-       if(is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       };
-
-       require_once('include/session.php');
        require_once('include/datetime.php');
        require_once('include/ostatus.php');
        require_once('include/post_update.php');
        require_once('mod/nodeinfo.php');
 
-       Config::load();
-
-       $a->set_baseurl(get_config('system','url'));
-
        // No parameter set? So return
        if ($argc <= 1)
                return;
@@ -71,8 +41,3 @@ function cronjobs_run(&$argv, &$argc){
 
        return;
 }
-
-if (array_search(__file__,get_included_files())===0){
-       cronjobs_run($_SERVER["argv"],$_SERVER["argc"]);
-       killme();
-}
index 8408ad1882fad73d9ed0df254d1caecf276b8809..bff4ff2a24946a9246513306add33c8fdedafe72 100644 (file)
@@ -5,26 +5,8 @@
  */
 
 use \Friendica\Core\Config;
-use \Friendica\Core\PConfig;
-
-require_once("boot.php");
 
 function dbclean_run(&$argv, &$argc) {
-       global $a, $db;
-
-       if (is_null($a)) {
-               $a = new App;
-       }
-
-       if (is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       }
-
-       Config::load();
-
        if (!Config::get('system', 'dbclean', false)) {
                return;
        }
@@ -35,7 +17,7 @@ function dbclean_run(&$argv, &$argc) {
                $stage = 0;
        }
 
-       if (Config::get("system", "worker") AND ($stage == 0)) {
+       if ($stage == 0) {
                proc_run(PRIORITY_LOW, 'include/dbclean.php', 1);
                proc_run(PRIORITY_LOW, 'include/dbclean.php', 2);
                proc_run(PRIORITY_LOW, 'include/dbclean.php', 3);
@@ -56,12 +38,8 @@ function remove_orphans($stage = 0) {
 
        $count = 0;
 
-       // With activated worker we split the deletion in many small tasks
-       if (Config::get("system", "worker")) {
-               $limit = 1000;
-       } else {
-               $limit = 10000;
-       }
+       // We split the deletion in many small tasks
+       $limit = 1000;
 
        if (($stage == 1) OR ($stage == 0)) {
                logger("Deleting old global item entries from item table without user copy");
@@ -159,14 +137,9 @@ function remove_orphans($stage = 0) {
        }
 
        // Call it again if not all entries were purged
-       if (($stage != 0) AND ($count > 0) AND Config::get("system", "worker")) {
+       if (($stage != 0) AND ($count > 0)) {
                proc_run(PRIORITY_MEDIUM, 'include/dbclean.php');
        }
 
 }
-
-if (array_search(__file__,get_included_files())===0){
-  dbclean_run($_SERVER["argv"],$_SERVER["argc"]);
-  killme();
-}
 ?>
index 14709208fa758c634e70e706ce5d9a4634a0e8cf..21528c5730bf4affd04bbfc79c496f0507994373 100644 (file)
@@ -2,23 +2,8 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
-
 function dbupdate_run(&$argv, &$argc) {
-       global $a, $db;
-
-       if(is_null($a)){
-               $a = new App;
-       }
-
-       if(is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-                       unset($db_host, $db_user, $db_pass, $db_data);
-       }
-
-       Config::load();
+       global $a;
 
        // We are deleting the latest dbupdate entry.
        // This is done to avoid endless loops because the update was interupted.
@@ -26,8 +11,3 @@ function dbupdate_run(&$argv, &$argc) {
 
        update_db($a);
 }
-
-if (array_search(__file__,get_included_files())===0){
-  dbupdate_run($_SERVER["argv"],$_SERVER["argc"]);
-  killme();
-}
index 5000a1edb908a77e9fbcc6053cbb8921c40ba4c2..45ca68cf37b42484e72965495fbbec4cb822fe4e 100644 (file)
@@ -2,7 +2,6 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
 require_once('include/queue_fn.php');
 require_once('include/html2plain.php');
 require_once("include/Scrape.php");
@@ -11,35 +10,17 @@ require_once("include/ostatus.php");
 require_once("include/dfrn.php");
 
 function delivery_run(&$argv, &$argc){
-       global $a, $db;
+       global $a;
 
-       if (is_null($a)) {
-               $a = new App;
-       }
-
-       if (is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       }
-
-       require_once("include/session.php");
        require_once("include/datetime.php");
        require_once('include/items.php');
        require_once('include/bbcode.php');
        require_once('include/email.php');
 
-       Config::load();
-
-       load_hooks();
-
        if ($argc < 3) {
                return;
        }
 
-       $a->set_baseurl(get_config('system','url'));
-
        logger('delivery: invoked: '. print_r($argv,true), LOGGER_DEBUG);
 
        $cmd        = $argv[1];
@@ -577,8 +558,3 @@ function delivery_run(&$argv, &$argc){
 
        return;
 }
-
-if (array_search(__file__,get_included_files())===0){
-  delivery_run($_SERVER["argv"],$_SERVER["argc"]);
-  killme();
-}
index 2ca367d369442dc1a31bed67ad81cc1f64659a7e..057c156ad7abb99b46867deef5d1dfcdd3e7f990 100644 (file)
@@ -1,36 +1,16 @@
 <?php
-require_once("boot.php");
-
 use \Friendica\Core\Config;
 
 function directory_run(&$argv, &$argc){
-       global $a, $db;
-
-       if(is_null($a)) {
-               $a = new App;
-       }
-
-       if(is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-                               unset($db_host, $db_user, $db_pass, $db_data);
-       };
-
-       Config::load();
-
-       if($argc != 2)
+       if ($argc != 2) {
                return;
-
-       load_hooks();
-
-
-       $a->set_baseurl(get_config('system','url'));
+       }
 
        $dir = get_config('system','directory');
 
-       if(! strlen($dir))
+       if (!strlen($dir)) {
                return;
+       }
 
        $dir .= "/submit";
 
@@ -39,13 +19,8 @@ function directory_run(&$argv, &$argc){
        call_hooks('globaldir_update', $arr);
 
        logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
-       if(strlen($arr['url']))
+       if (strlen($arr['url'])) {
                fetch_url($dir . '?url=' . bin2hex($arr['url']));
-
+       }
        return;
 }
-
-if (array_search(__file__,get_included_files())===0){
-  directory_run($_SERVER["argv"],$_SERVER["argc"]);
-  killme();
-}
index 8146368784cb4691aef3711510eb8ebf59434a13..6308a982afab8e0db4ce3753e90f19b923ff9371 100644 (file)
@@ -2,34 +2,12 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
 require_once("include/socgraph.php");
+require_once('include/datetime.php');
 
 function discover_poco_run(&$argv, &$argc){
-       global $a, $db;
 
-       if(is_null($a)) {
-               $a = new App;
-       }
-
-       if(is_null($db)) {
-           @include(".htconfig.php");
-       require_once("include/dba.php");
-           $db = new dba($db_host, $db_user, $db_pass, $db_data);
-       unset($db_host, $db_user, $db_pass, $db_data);
-       };
-
-       require_once('include/session.php');
-       require_once('include/datetime.php');
-
-       Config::load();
-
-       // Don't check this stuff if the function is called by the poller
-       if (App::callstack() != "poller_run")
-               if ($a->maxload_reached())
-                       return;
-
-       if(($argc > 2) && ($argv[1] == "dirsearch")) {
+       if (($argc > 2) && ($argv[1] == "dirsearch")) {
                $search = urldecode($argv[2]);
                $mode = 1;
        } elseif(($argc == 2) && ($argv[1] == "checkcontact")) {
@@ -42,15 +20,6 @@ function discover_poco_run(&$argv, &$argc){
        } else
                die("Unknown or missing parameter ".$argv[1]."\n");
 
-       // Don't check this stuff if the function is called by the poller
-       if (App::callstack() != "poller_run")
-               if (App::is_already_running('discover_poco'.$mode.urlencode($search), 'include/discover_poco.php', 1140))
-                       return;
-
-       $a->set_baseurl(get_config('system','url'));
-
-       load_hooks();
-
        logger('start '.$search);
 
        if ($mode==3)
@@ -207,9 +176,3 @@ function gs_search_user($search) {
                }
        }
 }
-
-
-if (array_search(__file__,get_included_files())===0){
-  discover_poco_run($_SERVER["argv"],$_SERVER["argc"]);
-  killme();
-}
index 855d7fb5e44abc544f7eb5f7f5364e7bd05253f6..35b109a50a487156ac53fe3d3ec66bfb1c9906e6 100644 (file)
@@ -2,32 +2,13 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
-
 function expire_run(&$argv, &$argc){
-       global $a, $db;
-
-       if(is_null($a)) {
-               $a = new App;
-       }
+       global $a;
 
-       if(is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       };
-
-       require_once('include/session.php');
        require_once('include/datetime.php');
        require_once('include/items.php');
        require_once('include/Contact.php');
 
-       Config::load();
-
-       $a->set_baseurl(get_config('system','url'));
-
-
        // physically remove anything that has been deleted for more than two months
 
        $r = q("delete from item where deleted = 1 and changed < UTC_TIMESTAMP() - INTERVAL 60 DAY");
@@ -53,8 +34,3 @@ function expire_run(&$argv, &$argc){
 
        return;
 }
-
-if (array_search(__file__,get_included_files())===0){
-  expire_run($_SERVER["argv"],$_SERVER["argc"]);
-  killme();
-}
index 4407fa6d6c5ee77cba0dfcdb40c654a3ecd82c8b..2f1758f377844a6fb96b2ddc1589f2cce658100c 100644 (file)
@@ -2,33 +2,11 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
 require_once('include/Scrape.php');
 require_once('include/socgraph.php');
+require_once('include/datetime.php');
 
 function gprobe_run(&$argv, &$argc){
-       global $a, $db;
-
-       if(is_null($a)) {
-               $a = new App;
-       }
-
-       if(is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       };
-
-       require_once('include/session.php');
-       require_once('include/datetime.php');
-
-       Config::load();
-
-       $a->set_baseurl(get_config('system','url'));
-
-       load_hooks();
-
        if($argc != 2)
                return;
 
@@ -74,8 +52,3 @@ function gprobe_run(&$argv, &$argc){
        logger("gprobe end for ".normalise_link($url), LOGGER_DEBUG);
        return;
 }
-
-if (array_search(__file__,get_included_files())===0){
-       gprobe_run($_SERVER["argv"],$_SERVER["argc"]);
-       killme();
-}
index 24830a11ab336f20194ab96aa4580f65b8fd9ca3..c05d00e63fdb062860c2358ff07ff87b8cd41c16 100644 (file)
@@ -2,7 +2,6 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
 require_once('include/queue_fn.php');
 require_once('include/html2plain.php');
 require_once("include/Scrape.php");
@@ -44,35 +43,17 @@ require_once('include/salmon.php');
 
 
 function notifier_run(&$argv, &$argc){
-       global $a, $db;
+       global $a;
 
-       if (is_null($a)) {
-               $a = new App;
-       }
-
-       if (is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-                       unset($db_host, $db_user, $db_pass, $db_data);
-       }
-
-       require_once("include/session.php");
        require_once("include/datetime.php");
        require_once('include/items.php');
        require_once('include/bbcode.php');
        require_once('include/email.php');
 
-       Config::load();
-
-       load_hooks();
-
        if ($argc < 3) {
                return;
        }
 
-       $a->set_baseurl(get_config('system','url'));
-
        logger('notifier: invoked: ' . print_r($argv,true), LOGGER_DEBUG);
 
        $cmd = $argv[1];
@@ -495,12 +476,6 @@ function notifier_run(&$argv, &$argc){
                );
        }
 
-       $interval = ((get_config('system','delivery_interval') === false) ? 2 : intval(get_config('system','delivery_interval')));
-
-       // If we are using the worker we don't need a delivery interval
-       if (get_config("system", "worker")) {
-               $interval = false;
-       }
        // delivery loop
 
        if (dbm::is_result($r)) {
@@ -517,26 +492,6 @@ function notifier_run(&$argv, &$argc){
                        }
                }
 
-
-               // This controls the number of deliveries to execute with each separate delivery process.
-               // By default we'll perform one delivery per process. Assuming a hostile shared hosting
-               // provider, this provides the greatest chance of deliveries if processes start getting
-               // killed. We can also space them out with the delivery_interval to also help avoid them
-               // getting whacked.
-
-               // If $deliveries_per_process > 1, we will chain this number of multiple deliveries
-               // together into a single process. This will reduce the overall number of processes
-               // spawned for each delivery, but they will run longer.
-
-               // When using the workerqueue, we don't need this functionality.
-
-               $deliveries_per_process = intval(get_config('system','delivery_batch_count'));
-               if (($deliveries_per_process <= 0) OR get_config("system", "worker")) {
-                       $deliveries_per_process = 1;
-               }
-
-               $this_batch = array();
-
                for ($x = 0; $x < count($r); $x ++) {
                        $contact = $r[$x];
 
@@ -545,25 +500,9 @@ function notifier_run(&$argv, &$argc){
                        }
                        logger("Deliver ".$target_item["guid"]." to ".$contact['url']." via network ".$contact['network'], LOGGER_DEBUG);
 
-                       // potentially more than one recipient. Start a new process and space them out a bit.
-                       // we will deliver single recipient types of message and email recipients here.
-
-                       $this_batch[] = $contact['id'];
-
-                       if (count($this_batch) >= $deliveries_per_process) {
-                               proc_run(PRIORITY_HIGH,'include/delivery.php',$cmd,$item_id,$this_batch);
-                               $this_batch = array();
-                               if ($interval) {
-                                       @time_sleep_until(microtime(true) + (float) $interval);
-                               }
-                       }
+                       proc_run(PRIORITY_HIGH,'include/delivery.php', $cmd, $item_id, $contact['id']);
                        continue;
                }
-
-               // be sure to pick up any stragglers
-               if (count($this_batch)) {
-                       proc_run(PRIORITY_HIGH,'include/delivery.php',$cmd,$item_id,$this_batch);
-               }
        }
 
        // send salmon slaps to mentioned remote tags (@foo@example.com) in OStatus posts
@@ -639,9 +578,6 @@ function notifier_run(&$argv, &$argc){
                                if ((! $mail) && (! $fsuggest) && (! $followup)) {
                                        logger('notifier: delivery agent: '.$rr['name'].' '.$rr['id'].' '.$rr['network'].' '.$target_item["guid"]);
                                        proc_run(PRIORITY_HIGH,'include/delivery.php',$cmd,$item_id,$rr['id']);
-                                       if ($interval) {
-                                               @time_sleep_until(microtime(true) + (float) $interval);
-                                       }
                                }
                        }
                }
@@ -694,9 +630,3 @@ function notifier_run(&$argv, &$argc){
 
        return;
 }
-
-
-if (array_search(__file__,get_included_files())===0){
-       notifier_run($_SERVER["argv"],$_SERVER["argc"]);
-       killme();
-}
index 5219d9f3bd5f291ec52c8fa8dd7e81814bf12fbb..9e156751b939adb55434ecbe69b1b9c8887cc8ac 100644 (file)
@@ -2,7 +2,6 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
 require_once("include/follow.php");
 
 function RemoveReply($subject) {
@@ -13,20 +12,8 @@ function RemoveReply($subject) {
 }
 
 function onepoll_run(&$argv, &$argc){
-       global $a, $db;
+       global $a;
 
-       if(is_null($a)) {
-               $a = new App;
-       }
-
-       if(is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       };
-
-       require_once('include/session.php');
        require_once('include/datetime.php');
        require_once('include/items.php');
        require_once('include/Contact.php');
@@ -34,12 +21,6 @@ function onepoll_run(&$argv, &$argc){
        require_once('include/socgraph.php');
        require_once('include/queue_fn.php');
 
-       Config::load();
-
-       $a->set_baseurl(get_config('system','url'));
-
-       load_hooks();
-
        logger('onepoll: start');
 
        $manual_id  = 0;
@@ -59,11 +40,6 @@ function onepoll_run(&$argv, &$argc){
                return;
        }
 
-       // Don't check this stuff if the function is called by the poller
-       if (App::callstack() != "poller_run")
-               if (App::is_already_running('onepoll'.$contact_id, '', 540))
-                       return;
-
        $d = datetime_convert();
 
        // Only poll from those with suitable relationships,
@@ -670,8 +646,3 @@ function onepoll_run(&$argv, &$argc){
 
        return;
 }
-
-if (array_search(__file__,get_included_files())===0){
-       onepoll_run($_SERVER["argv"],$_SERVER["argc"]);
-       killme();
-}
index 8be4c1835c4847277b6f2c5eddee34a42e29bc39..06297351632db18b828016ef8c5b4f1027733047 100644 (file)
@@ -35,6 +35,10 @@ function poller_run($argv, $argc){
                return;
        }
 
+       $a->set_baseurl(Config::get('system', 'url'));
+
+       load_hooks();
+
        $a->start_process();
 
        if (poller_max_connections_reached()) {
@@ -561,7 +565,7 @@ function poller_worker_process() {
  * @brief Call the front end worker
  */
 function call_worker() {
-       if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) {
+       if (!Config::get("system", "frontend_worker")) {
                return;
        }
 
@@ -573,7 +577,7 @@ function call_worker() {
  * @brief Call the front end worker if there aren't any active
  */
 function call_worker_if_idle() {
-       if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) {
+       if (!Config::get("system", "frontend_worker")) {
                return;
        }
 
index 428103a9713e5616f342a509d38f4cb1c016394d..f88ca98a49a6f7b848f24f496bd5e1abd9ce61a8 100644 (file)
@@ -1,12 +1,31 @@
 <?php
-require_once("boot.php");
+use \Friendica\Core\Config;
+
+require_once('include/items.php');
 require_once("include/ostatus.php");
 
-use \Friendica\Core\Config;
-use \Friendica\Core\PConfig;
+function pubsubpublish_run(&$argv, &$argc){
+
+       if ($argc > 1) {
+               $pubsubpublish_id = intval($argv[1]);
+       } else {
+               // We'll push to each subscriber that has push > 0,
+               // i.e. there has been an update (set in notifier.php).
+               $r = q("SELECT `id`, `callback_url` FROM `push_subscriber` WHERE `push` > 0");
+
+               foreach ($r as $rr) {
+                       logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
+                       proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]);
+               }
+       }
+
+       handle_pubsubhubbub($pubsubpublish_id);
+
+       return;
+}
 
 function handle_pubsubhubbub($id) {
-       global $a, $db;
+       global $a;
 
        $r = q("SELECT * FROM `push_subscriber` WHERE `id` = %d", intval($id));
        if (!$r)
@@ -54,70 +73,3 @@ function handle_pubsubhubbub($id) {
                        intval($rr['id']));
        }
 }
-
-
-function pubsubpublish_run(&$argv, &$argc){
-       global $a, $db;
-
-       if(is_null($a)){
-               $a = new App;
-       }
-
-       if(is_null($db)){
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       };
-
-       require_once('include/items.php');
-
-       Config::load();
-
-       // Don't check this stuff if the function is called by the poller
-       if (App::callstack() != "poller_run") {
-               if (App::is_already_running("pubsubpublish", "include/pubsubpublish.php", 540)) {
-                       return;
-               }
-       }
-
-       $a->set_baseurl(get_config('system','url'));
-
-       load_hooks();
-
-       if ($argc > 1) {
-               $pubsubpublish_id = intval($argv[1]);
-       }
-       else {
-               // We'll push to each subscriber that has push > 0,
-               // i.e. there has been an update (set in notifier.php).
-               $r = q("SELECT `id`, `callback_url` FROM `push_subscriber` WHERE `push` > 0");
-
-               // Use the delivery interval that is also used for the notifier
-               $interval = Config::get("system", "delivery_interval", 2);
-
-               // If we are using the worker we don't need a delivery interval
-               if (get_config("system", "worker")) {
-                       $interval = false;
-               }
-
-               foreach ($r as $rr) {
-                       logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
-                       proc_run(PRIORITY_HIGH, 'include/pubsubpublish.php', $rr["id"]);
-
-                       if($interval)
-                               @time_sleep_until(microtime(true) + (float) $interval);
-               }
-       }
-
-       handle_pubsubhubbub($pubsubpublish_id);
-
-       return;
-
-}
-
-if (array_search(__file__,get_included_files())===0){
-  pubsubpublish_run($_SERVER["argv"],$_SERVER["argc"]);
-  killme();
-}
-
index bcd32985db890d2ea1d36f3e495e2a9278f66ea5..6bbfdaae81bde776e6eafbecffdab9e46ef2a27a 100644 (file)
@@ -1,41 +1,18 @@
 <?php
 
+/// @todo Rework the whole file to a single item processing
+
 use \Friendica\Core\Config;
 
-require_once("boot.php");
 require_once('include/queue_fn.php');
 require_once('include/dfrn.php');
+require_once("include/datetime.php");
+require_once('include/items.php');
+require_once('include/bbcode.php');
+require_once('include/socgraph.php');
 
 function queue_run(&$argv, &$argc){
-       global $a, $db;
-
-       if(is_null($a)){
-               $a = new App;
-       }
-
-       if(is_null($db)){
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       };
-
-       require_once("include/session.php");
-       require_once("include/datetime.php");
-       require_once('include/items.php');
-       require_once('include/bbcode.php');
-       require_once('include/socgraph.php');
-
-       Config::load();
-
-       // Don't check this stuff if the function is called by the poller
-       if (App::callstack() != "poller_run")
-               if (App::is_already_running('queue', 'include/queue.php', 540))
-                       return;
-
-       $a->set_baseurl(get_config('system','url'));
-
-       load_hooks();
+       global $a;
 
        if($argc > 1)
                $queue_id = intval($argv[1]);
@@ -53,20 +30,11 @@ function queue_run(&$argv, &$argc){
                // Handling the pubsubhubbub requests
                proc_run(PRIORITY_HIGH,'include/pubsubpublish.php');
 
-               $interval = ((get_config('system','delivery_interval') === false) ? 2 : intval(get_config('system','delivery_interval')));
-
-               // If we are using the worker we don't need a delivery interval
-               if (get_config("system", "worker"))
-                       $interval = false;
-
                $r = q("select * from deliverq where 1");
                if ($r) {
                        foreach ($r as $rr) {
                                logger('queue: deliverq');
                                proc_run(PRIORITY_HIGH,'include/delivery.php',$rr['cmd'],$rr['item'],$rr['contact']);
-                               if($interval) {
-                                       time_sleep_until(microtime(true) + (float) $interval);
-                               }
                        }
                }
 
@@ -111,16 +79,14 @@ function queue_run(&$argv, &$argc){
                // queue_predeliver hooks may have changed the queue db details,
                // so check again if this entry still needs processing
 
-               if($queue_id)
+               if ($queue_id) {
                        $qi = q("SELECT * FROM `queue` WHERE `id` = %d LIMIT 1",
                                intval($queue_id));
-               elseif (get_config("system", "worker")) {
+               } else {
                        logger('Call queue for id '.$q_item['id']);
                        proc_run(PRIORITY_LOW, "include/queue.php", $q_item['id']);
                        continue;
-               } else
-                       $qi = q("SELECT * FROM `queue` WHERE `id` = %d AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ",
-                               intval($q_item['id']));
+               }
 
                if(! count($qi))
                        continue;
@@ -225,10 +191,4 @@ function queue_run(&$argv, &$argc){
        }
 
        return;
-
-}
-
-if (array_search(__file__,get_included_files())===0){
-  queue_run($_SERVER["argv"],$_SERVER["argc"]);
-  killme();
 }
index aa206211160ad1d14a13e38574cbe94c371adc29..68bf2adfeaa103c22f3849dd30dc3e997a4741d0 100644 (file)
@@ -6,24 +6,7 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
-
 function remove_contact_run($argv, $argc) {
-       global $a, $db;
-
-       if (is_null($a)) {
-               $a = new App;
-       }
-
-       if (is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       }
-
-       Config::load();
-
        if ($argc != 2) {
                return;
        }
@@ -46,9 +29,4 @@ function remove_contact_run($argv, $argc) {
 
        q("DELETE FROM `queue` WHERE `cid` = %d", intval($id));
 }
-
-if (array_search(__file__, get_included_files()) === 0) {
-       remove_contact_run($_SERVER["argv"], $_SERVER["argc"]);
-       killme();
-}
 ?>
index 83a785fe1fdd88b3455685861354b27ad73d3594..5b0a1b94b0af3f9b530a36db860163d576f71667 100644 (file)
@@ -5,20 +5,26 @@ use \Friendica\Core\Config;
 require_once("boot.php");
 require_once("include/threads.php");
 
-global $a, $db;
+function shadowupdate_run(&$argv, &$argc){
+       global $a, $db;
 
-if(is_null($a))
-       $a = new App;
+       if (is_null($a)) {
+               $a = new App;
+       }
 
-if(is_null($db)) {
-       @include(".htconfig.php");
-       require_once("include/dba.php");
-       $db = new dba($db_host, $db_user, $db_pass, $db_data);
-       unset($db_host, $db_user, $db_pass, $db_data);
-}
+       if (is_null($db)) {
+               @include(".htconfig.php");
+               require_once("include/dba.php");
+               $db = new dba($db_host, $db_user, $db_pass, $db_data);
+               unset($db_host, $db_user, $db_pass, $db_data);
+       }
+
+       Config::load();
 
-Config::load();
+       update_shadow_copy();
+}
 
-update_shadow_copy();
-killme();
-?>
+if (array_search(__file__,get_included_files())===0){
+       shadowupdate_run($_SERVER["argv"],$_SERVER["argc"]);
+       killme();
+}
index b4cce46b57eb6c9b02bbb09a6f35e5a913b09ac8..f64b39e4b687bda0e0b42434ed88c2872367c463 100644 (file)
@@ -6,24 +6,10 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
 require_once("include/items.php");
 
 function spool_post_run($argv, $argc) {
-       global $a, $db;
-
-       if (is_null($a)) {
-               $a = new App;
-       }
-
-       if (is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       }
-
-       Config::load();
+       global $a;
 
        $path = get_spoolpath();
 
@@ -69,9 +55,4 @@ function spool_post_run($argv, $argc) {
                }
        }
 }
-
-if (array_search(__file__, get_included_files()) === 0) {
-       spool_post_run($_SERVER["argv"], $_SERVER["argc"]);
-       killme();
-}
 ?>
index b4de121e9f7c1bc08a2a87cd54f5c57f713a675b..1e97135c5b05fa6a038b3b6f001f3471be175bee 100644 (file)
@@ -1,24 +1,6 @@
 <?php
-
-use \Friendica\Core\Config;
-
-require_once("boot.php");
 require_once("include/tags.php");
 
-global $a, $db;
-
-if(is_null($a))
-       $a = new App;
-
-if(is_null($db)) {
-       @include(".htconfig.php");
-       require_once("include/dba.php");
-       $db = new dba($db_host, $db_user, $db_pass, $db_data);
-       unset($db_host, $db_user, $db_pass, $db_data);
+function tagupdate_run(&$argv, &$argc){
+       update_items();
 }
-
-Config::load();
-
-update_items();
-killme();
-?>
index dc528c6b87105d1a34871508399df9dca14d603e..3a4028603eb7236ce7da362c0f3a26a70fd27bc5 100644 (file)
@@ -1,25 +1,7 @@
 <?php
-
-use \Friendica\Core\Config;
-
-require_once("boot.php");
 require_once("include/threads.php");
 
-global $a, $db;
-
-if(is_null($a))
-       $a = new App;
-
-if(is_null($db)) {
-       @include(".htconfig.php");
-       require_once("include/dba.php");
-       $db = new dba($db_host, $db_user, $db_pass, $db_data);
-       unset($db_host, $db_user, $db_pass, $db_data);
+function threadupdate_run(&$argv, &$argc){
+       update_threads();
+       update_threads_mention();
 }
-
-Config::load();
-
-update_threads();
-update_threads_mention();
-killme();
-?>
index 6aa8bcac29858e58127169e22f22388af50b2eb5..f59f487653c09e103a80bedf89445e5f413722ff 100644 (file)
@@ -2,31 +2,12 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
-
 function update_gcontact_run(&$argv, &$argc){
-       global $a, $db;
-
-       if(is_null($a)) {
-               $a = new App;
-       }
-
-       if(is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       };
+       global $a;
 
        require_once('include/Scrape.php');
        require_once("include/socgraph.php");
 
-       Config::load();
-
-       $a->set_baseurl(get_config('system','url'));
-
-       load_hooks();
-
        logger('update_gcontact: start');
 
        if(($argc > 1) && (intval($argv[1])))
@@ -37,11 +18,6 @@ function update_gcontact_run(&$argv, &$argc){
                return;
        }
 
-       // Don't check this stuff if the function is called by the poller
-       if (App::callstack() != "poller_run")
-               if (App::is_already_running('update_gcontact'.$contact_id, '', 540))
-                       return;
-
        $r = q("SELECT * FROM `gcontact` WHERE `id` = %d", intval($contact_id));
 
        if (!$r)
@@ -98,8 +74,3 @@ function update_gcontact_run(&$argv, &$argc){
                                dbesc(normalise_link($data["url"]))
                        );
 }
-
-if (array_search(__file__,get_included_files())===0){
-       update_gcontact_run($_SERVER["argv"],$_SERVER["argc"]);
-       killme();
-}
index c202a28d64d95feb1765485efad7733ab3fa96c3..4949b830f4866c4863eb5fe99d363e35e06077a6 100644 (file)
@@ -10,7 +10,7 @@ use \Friendica\Core\PConfig;
 
 function worker_init($a){
 
-       if (!Config::get("system", "frontend_worker") OR !Config::get("system", "worker")) {
+       if (!Config::get("system", "frontend_worker")) {
                return;
        }
 
index 2edfddb885f277bbae863ea9cf1b0b2ea04c494f..df50c0fb48505c549456ec487c65a901105ce163 100644 (file)
        {{include file="field_input.tpl" field=$proxy}}
        {{include file="field_input.tpl" field=$proxyuser}}
        {{include file="field_input.tpl" field=$timeout}}
-       {{if NOT $worker.2}}
-               {{include file="field_input.tpl" field=$delivery_interval}}
-               {{include file="field_input.tpl" field=$poll_interval}}
-       {{/if}}
        {{include file="field_input.tpl" field=$maxloadavg}}
        {{include file="field_input.tpl" field=$maxloadavg_frontend}}
        {{include file="field_input.tpl" field=$optimize_max_tablesize}}
        <div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
 
        <h3>{{$worker_title}}</h3>
-       {{include file="field_checkbox.tpl" field=$worker}}
-       {{if $worker.2}}
-               {{include file="field_input.tpl" field=$worker_queues}}
-               {{include file="field_checkbox.tpl" field=$worker_dont_fork}}
-               {{include file="field_checkbox.tpl" field=$worker_fastlane}}
-               {{include file="field_checkbox.tpl" field=$worker_frontend}}
-       {{/if}}
+       {{include file="field_input.tpl" field=$worker_queues}}
+       {{include file="field_checkbox.tpl" field=$worker_dont_fork}}
+       {{include file="field_checkbox.tpl" field=$worker_fastlane}}
+       {{include file="field_checkbox.tpl" field=$worker_frontend}}
        <div class="submit"><input type="submit" name="page_site" value="{{$submit|escape:'html'}}" /></div>
 
        </form>
index c8e8af22945ff36afc3defa4fcb651fd4dcc1b80..a8243b6149f57dcb96637655c45327aa9be9f726 100644 (file)
@@ -11,7 +11,7 @@
 
        <dl>
                <dt>{{$queues.label}}</dt>
-               <dd>{{$queues.deliverq}} - <a href="{{$baseurl}}/admin/queue">{{$queues.queue}}</a>{{if $workeractive}} - {{$queues.workerq}}{{/if}}</dd>
+               <dd>{{$queues.deliverq}} - <a href="{{$baseurl}}/admin/queue">{{$queues.queue}}</a> - {{$queues.workerq}}</dd>
        </dl>
        <dl>
                <dt>{{$pending.0}}</dt>