diff options
author | redmatrix <git@macgirvin.com> | 2016-05-19 21:22:04 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-05-19 21:22:04 -0700 |
commit | 39bc0664a773a97ccce276161739f217e3ba7449 (patch) | |
tree | 726fff23174f4972337ad8aae6b8ff6544264a8b /Zotlabs/Daemon/Cron_daily.php | |
parent | 853322e7d2734ad459a4e5740f3f1806ed55532e (diff) | |
download | volse-hubzilla-39bc0664a773a97ccce276161739f217e3ba7449.tar.gz volse-hubzilla-39bc0664a773a97ccce276161739f217e3ba7449.tar.bz2 volse-hubzilla-39bc0664a773a97ccce276161739f217e3ba7449.zip |
Separate cron into periodic components and use that as the main interface for scheduled tasks instead of the quaint 'poller'.
Diffstat (limited to 'Zotlabs/Daemon/Cron_daily.php')
-rw-r--r-- | Zotlabs/Daemon/Cron_daily.php | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php new file mode 100644 index 000000000..fe667a139 --- /dev/null +++ b/Zotlabs/Daemon/Cron_daily.php @@ -0,0 +1,90 @@ +<?php /** @file */ + +namespace Zotlabs\Daemon; + +class Cron_daily { + + static public function run($argc,$argv) { + + logger('cron_daily: start'); + + /** + * Cron Daily + * + */ + + + require_once('include/dir_fns.php'); + check_upstream_directory(); + + + // Fire off the Cron_weekly process if it's the correct day. + + $d3 = intval(datetime_convert('UTC','UTC','now','N')); + if($d3 == 7) { + Master::Summon('Cron_weekly'); + } + + // once daily run birthday_updates and then expire in background + + // FIXME: add birthday updates, both locally and for xprof for use + // by directory servers + + update_birthdays(); + + // expire any read notifications over a month old + + q("delete from notify where seen = 1 and date < %s - INTERVAL %s", + db_utcnow(), db_quoteinterval('30 DAY') + ); + + //update statistics in config + require_once('include/statistics_fns.php'); + update_channels_total_stat(); + update_channels_active_halfyear_stat(); + update_channels_active_monthly_stat(); + update_local_posts_stat(); + + + // expire old delivery reports + + $keep_reports = intval(get_config('system','expire_delivery_reports')); + if($keep_reports === 0) + $keep_reports = 10; + + q("delete from dreport where dreport_time < %s - INTERVAL %s", + db_utcnow(), + db_quoteinterval($keep_reports . ' DAY') + ); + + // expire any expired accounts + downgrade_accounts(); + + // If this is a directory server, request a sync with an upstream + // directory at least once a day, up to once every poll interval. + // Pull remote changes and push local changes. + // potential issue: how do we keep from creating an endless update loop? + + $dirmode = get_config('system','directory_mode'); + + if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) { + require_once('include/dir_fns.php'); + sync_directories($dirmode); + } + + + Master::Summon(array('Expire')); + Master::Summon(array('Cli_suggest')); + + require_once('include/hubloc.php'); + remove_obsolete_hublocs(); + + call_hooks('cron_daily',datetime_convert()); + + set_config('system','last_expire_day',$d2); + + /** + * End Cron Daily + */ + } +} |