X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fcronhooks.php;h=af5ab9f922cf4046554595e62d530345d730ca28;hb=99fb15037bde3017b8fe270ddcaa802548f5ed8c;hp=8c70008e453c913e9318184ed859e161ed68eb6a;hpb=c00772204100a44267c38f7a2533268b5dff1248;p=friendica.git diff --git a/include/cronhooks.php b/include/cronhooks.php index 8c70008e45..af5ab9f922 100644 --- a/include/cronhooks.php +++ b/include/cronhooks.php @@ -1,39 +1,19 @@ $maxsysload) { - logger('system: load ' . $load . ' too high. Cronhooks deferred to next scheduled run.'); - return; - } + 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]) { + logger("Calling cron hook '".$hook[1]."'", LOGGER_DEBUG); + call_single_hook($a, $name, $hook, $data); + } + return; } $last = get_config('system','last_cronhook'); @@ -50,30 +30,18 @@ function cronhooks_run(&$argv, &$argc){ } } - $lockpath = get_lockpath(); - if ($lockpath != '') { - $pidfile = new pidfile($lockpath, 'cronhooks'); - if($pidfile->is_already_running()) { - logger("cronhooks: Already running"); - if ($pidfile->running_time() > 19*60) { - $pidfile->kill(); - logger("cronhooks: killed stale process"); - // Calling a new instance - proc_run('php','include/cronhooks.php'); - } - exit; - } - } - $a->set_baseurl(get_config('system','url')); - load_hooks(); - logger('cronhooks: start'); $d = datetime_convert(); - call_hooks('cron', $d); + 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]); + } + } logger('cronhooks: end'); @@ -81,8 +49,3 @@ function cronhooks_run(&$argv, &$argc){ return; } - -if (array_search(__file__,get_included_files())===0){ - cronhooks_run($_SERVER["argv"],$_SERVER["argc"]); - killme(); -}