Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

72 lines
1.5 KiB

  1. <?php
  2. require_once("boot.php");
  3. function cronhooks_run(&$argv, &$argc){
  4. global $a, $db;
  5. if(is_null($a)) {
  6. $a = new App;
  7. }
  8. if(is_null($db)) {
  9. @include(".htconfig.php");
  10. require_once("include/dba.php");
  11. $db = new dba($db_host, $db_user, $db_pass, $db_data);
  12. unset($db_host, $db_user, $db_pass, $db_data);
  13. };
  14. require_once('include/session.php');
  15. require_once('include/datetime.php');
  16. require_once('include/pidfile.php');
  17. load_config('config');
  18. load_config('system');
  19. $maxsysload = intval(get_config('system','maxloadavg'));
  20. if($maxsysload < 1)
  21. $maxsysload = 50;
  22. if(function_exists('sys_getloadavg')) {
  23. $load = sys_getloadavg();
  24. if(intval($load[0]) > $maxsysload) {
  25. logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.');
  26. return;
  27. }
  28. }
  29. $lockpath = get_lockpath();
  30. if ($lockpath != '') {
  31. $pidfile = new pidfile($lockpath, 'cronhooks');
  32. if($pidfile->is_already_running()) {
  33. logger("cronhooks: Already running");
  34. if ($pidfile->running_time() > 9*60) {
  35. $pidfile->kill();
  36. logger("cronhooks: killed stale process");
  37. // Calling a new instance
  38. proc_run('php','include/cronhooks.php');
  39. }
  40. exit;
  41. }
  42. }
  43. $a->set_baseurl(get_config('system','url'));
  44. load_hooks();
  45. logger('cronhooks: start');
  46. $d = datetime_convert();
  47. call_hooks('cron', $d);
  48. logger('cronhooks: end');
  49. return;
  50. }
  51. if (array_search(__file__,get_included_files())===0){
  52. cronhooks_run($argv,$argc);
  53. killme();
  54. }