aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-03-02 18:02:06 -0800
committerfriendica <info@friendica.com>2015-03-02 18:02:06 -0800
commit37384c0b27eee39d4a81a4f0dac3565375155082 (patch)
treea0f20e46dcfd1d8666e7b39bef11b75b693bcb7b
parente6eee5ba92bc64ea0c9855831bddf66acccd9bee (diff)
downloadvolse-hubzilla-37384c0b27eee39d4a81a4f0dac3565375155082.tar.gz
volse-hubzilla-37384c0b27eee39d4a81a4f0dac3565375155082.tar.bz2
volse-hubzilla-37384c0b27eee39d4a81a4f0dac3565375155082.zip
automated warning after a few days if poller is dead
-rwxr-xr-xboot.php43
-rwxr-xr-xindex.php3
-rw-r--r--view/en/cron_bad_eml.tpl17
3 files changed, 63 insertions, 0 deletions
diff --git a/boot.php b/boot.php
index f0f982e03..06813099f 100755
--- a/boot.php
+++ b/boot.php
@@ -2296,4 +2296,47 @@ function cert_bad_email() {
. 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit' );
+}
+
+
+// send warnings every 3-5 days if cron is not running.
+
+
+function check_cron_broken() {
+
+ $t = get_config('system','lastpollcheck');
+ if(! $t) {
+ // never checked before. Start the timer.
+ set_config('system','lastpollcheck',datetime_convert());
+ return;
+ }
+ if($t > datetime_convert('UTC','UTC','now - 3 days')) {
+ // Wait for 3 days before we do anything so as not to swamp the admin with messages
+ return;
+ }
+
+ $d = get_config('system','lastpoll');
+ if(($d) && ($d > datetime_convert('UTC','UTC','now - 3 days'))) {
+ // Scheduled tasks have run successfully in the last 3 days.
+ set_config('system','lastpollcheck',datetime_convert());
+ return;
+ }
+
+ $a = get_app();
+
+ $email_tpl = get_intltext_template("cron_bad_eml.tpl");
+ $email_msg = replace_macros($email_tpl, array(
+ '$sitename' => $a->config['system']['sitename'],
+ '$siteurl' => $a->get_baseurl(),
+ '$error' => t('Cron/Scheduled tasks not running.'),
+ '$lastdate' => (($d)? $d : t('never'))
+ ));
+
+ $subject = email_header_encode(sprintf(t('[red] Cron tasks not running on %s'), $a->get_hostname()));
+ mail($a->config['system']['admin_email'], $subject, $email_msg,
+ 'From: Administrator' . '@' . $a->get_hostname() . "\n"
+ . 'Content-type: text/plain; charset=UTF-8' . "\n"
+ . 'Content-transfer-encoding: 8bit' );
+ set_config('system','lastpollcheck',datetime_convert());
+ return;
} \ No newline at end of file
diff --git a/index.php b/index.php
index 94d22e415..716c24fe6 100755
--- a/index.php
+++ b/index.php
@@ -396,6 +396,9 @@ if(stristr( implode("",$_SESSION['sysmsg']), t('Permission denied'))) {
call_hooks('page_end', $a->page['content']);
+if(! $a->install)
+ check_cron_broken();
+
construct_page($a);
session_write_close();
diff --git a/view/en/cron_bad_eml.tpl b/view/en/cron_bad_eml.tpl
new file mode 100644
index 000000000..ce30dae73
--- /dev/null
+++ b/view/en/cron_bad_eml.tpl
@@ -0,0 +1,17 @@
+This is the webserver at {{$sitename}};
+
+A routine check indicates the scheduled maintenance tasks on this
+website are not running. Please review your "cron" jobs or the
+equivalent mechanism on your operating system and ensure these are
+running. Please review the INSTALL instructions if you are seeing
+this message for the first time. If these maintenance tasks have
+been running normally until now, please check to see if anything
+may have gone wrong to account for them not running currently.
+This check is run approximately every three days.
+
+The error message is '{{$error}}'.
+
+The last successful execution was '{{$lastdate}}'.
+
+Apologies for the inconvenience,
+ your web server at {{$siteurl}} \ No newline at end of file