X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=include%2Fcronhooks.php;h=af5ab9f922cf4046554595e62d530345d730ca28;hb=99fb15037bde3017b8fe270ddcaa802548f5ed8c;hp=096e10b718bd8ea51ff338f1b7a0bfa3e952c824;hpb=61020cf17406f72a7ad929f2d5ee9b8b7c94b52f;p=friendica.git diff --git a/include/cronhooks.php b/include/cronhooks.php index 096e10b718..af5ab9f922 100644 --- a/include/cronhooks.php +++ b/include/cronhooks.php @@ -1,56 +1,51 @@ 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'); - if ($hostname = get_config('system', 'hostname')) - $a->set_hostname($hostname); + $poll_interval = intval(get_config('system','cronhook_interval')); + if(! $poll_interval) + $poll_interval = 9; - $lockpath = get_config('system','lockpath'); - if ($lockpath != '') { - $pidfile = new pidfile($lockpath, 'cron.lck'); - if($pidfile->is_already_running()) { - logger("cronhooks: Already running"); - exit; + if($last) { + $next = $last + ($poll_interval * 60); + if($next > time()) { + logger('cronhook intervall not reached'); + return; } } $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]); + } + } - return; -} + logger('cronhooks: end'); -if (array_search(__file__,get_included_files())===0){ - cronhooks_run($argv,$argc); - killme(); + set_config('system','last_cronhook', time()); + + return; }