X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fcron.php;h=c60284b738a7d819f4c6f6e4601b7517a4032eb4;hb=6ff5c23d50095e5407bf69f8a4ec2220c5d2d408;hp=71af5d826f31a9faaa2e0baf7bd61c5c490bca96;hpb=b76dc8b129eeee465f1c288b1c4e6d726a0a0c9e;p=friendica.git diff --git a/include/cron.php b/include/cron.php index 71af5d826f..c60284b738 100644 --- a/include/cron.php +++ b/include/cron.php @@ -30,27 +30,21 @@ function cron_run(&$argv, &$argc){ require_once('include/session.php'); require_once('include/datetime.php'); - require_once('library/simplepie/simplepie.inc'); require_once('include/items.php'); require_once('include/Contact.php'); require_once('include/email.php'); require_once('include/socgraph.php'); - require_once('include/pidfile.php'); require_once('mod/nodeinfo.php'); load_config('config'); load_config('system'); - $maxsysload = intval(get_config('system','maxloadavg')); - if($maxsysload < 1) - $maxsysload = 50; - - $load = current_load(); - if($load) { - if(intval($load) > $maxsysload) { - logger('system: load ' . $load . ' too high. cron deferred to next scheduled run.'); + // Don't check this stuff if the function is called by the poller + if (App::callstack() != "poller_run") { + if (App::maxload_reached()) + return; + if (App::is_already_running('cron', 'include/cron.php', 540)) return; - } } $last = get_config('system','last_cron'); @@ -67,23 +61,6 @@ function cron_run(&$argv, &$argc){ } } - $lockpath = get_lockpath(); - if ($lockpath != '') { - $pidfile = new pidfile($lockpath, 'cron'); - if($pidfile->is_already_running()) { - logger("cron: Already running"); - if ($pidfile->running_time() > 9*60) { - $pidfile->kill(); - logger("cron: killed stale process"); - // Calling a new instance - proc_run('php','include/cron.php'); - } - exit; - } - } - - - $a->set_baseurl(get_config('system','url')); load_hooks(); @@ -94,10 +71,6 @@ function cron_run(&$argv, &$argc){ proc_run('php',"include/queue.php"); - // run diaspora photo queue process in the background - - proc_run('php',"include/dsprphotoq.php"); - // run the process to discover global contacts in the background proc_run('php',"include/discover_poco.php"); @@ -128,10 +101,10 @@ function cron_run(&$argv, &$argc){ // Check OStatus conversations // Check only conversations with mentions (for a longer time) - check_conversations(true); + ostatus::check_conversations(true); // Check every conversation - check_conversations(false); + ostatus::check_conversations(false); // Set the gcontact-id in the item table if missing item_set_gcontact(); @@ -380,7 +353,7 @@ function cron_clear_cache(&$a) { continue; // Calculate fragmentation - $fragmentation = $table["Data_free"] / $table["Data_length"]; + $fragmentation = $table["Data_free"] / ($table["Data_length"] + $table["Index_length"]); logger("Table ".$table["Name"]." - Fragmentation level: ".round($fragmentation * 100, 2), LOGGER_DEBUG); @@ -431,11 +404,10 @@ function cron_repair_database() { q("UPDATE `item` INNER JOIN `item` AS `parent` ON `parent`.`uri` = `item`.`parent-uri` AND `parent`.`uid` = `item`.`uid` SET `item`.`parent` = `parent`.`id` WHERE `item`.`parent` = 0"); /// @todo - // - remove duplicated contacts with uid=0 (We could do this at the place where the contacts are stored) - // - remove thread entries without item - // - remove sign entries without item - // - remove children when parent got lost - // - set contact-id in item when not present + /// - remove thread entries without item + /// - remove sign entries without item + /// - remove children when parent got lost + /// - set contact-id in item when not present } if (array_search(__file__,get_included_files())===0){