From: Andrew Dolgov Date: Mon, 16 Jul 2007 13:05:29 +0000 (+0100) Subject: check update daemon timestamp X-Git-Tag: 1.2.13~8 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=8e00ae9b58cceccaf10b7bf8600131b8d6e671a4;p=tt-rss.git check update daemon timestamp --- diff --git a/functions.php b/functions.php index 1aa6f32b..6376a282 100644 --- a/functions.php +++ b/functions.php @@ -1509,8 +1509,9 @@ function make_stampfile($filename) { $fp = fopen($filename, "w"); - if ($fp) { + if (flock($fp, LOCK_EX | LOCK_NB)) { fwrite($fp, time() . "\n"); + flock($fp, LOCK_UN); fclose($fp); return true; } else { @@ -1518,6 +1519,21 @@ } } + function read_stampfile($filename) { + + error_reporting(0); + $fp = fopen($filename, "r"); + error_reporting (DEFAULT_ERROR_LEVEL); + + if (flock($fp, LOCK_EX)) { + $stamp = fgets($fp); + flock($fp, LOCK_UN); + fclose($fp); + return $stamp; + } else { + return false; + } + } function sql_random_function() { if (DB_TYPE == "mysql") { @@ -2314,7 +2330,27 @@ if (ENABLE_UPDATE_DAEMON) { print ""; + + if ($_SESSION["daemon_stamp_check"] + 0 < time()) { + + $stamp = (int)read_stampfile("update_daemon.stamp"); + + if ($stamp) { + if ($stamp + 86400*3 < time()) { + print ""; + } else { + print ""; + } + + $stamp_fmt = date("Y.m.d, G:i", $stamp); + + print ""; + } + + $_SESSION["daemon_stamp_check"] = time(); + } } + if (CHECK_FOR_NEW_VERSION && $_SESSION["access_level"] >= 10) { if ($_SESSION["last_version_check"] + 600 < time()) { diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index ef9f1362..562093d9 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -26,6 +26,13 @@ } + if ($param == 3) { + print __("TT-RSS has detected that update daemon is taking too long to + perform a feed update. This could indicate a problem like crash + or a hang. Please check the daemon process or contact instance + owner."); + } + print ""; print "
"; diff --git a/tt-rss.js b/tt-rss.js index 96418db9..10f1a7ef 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -604,9 +604,19 @@ function parse_runtime_info(elem) { } } + var error_flag; + if (k == "daemon_is_running" && v != 1) { - notify_error("Update daemon is not running."); - } else { + notify_error("Update daemon is not running.", true); + error_flag = true; + } + + if (k == "daemon_stamp_ok" && v != 1) { + notify_error("Update daemon is not updating feeds.", true); + error_flag = true; + } + + if (!error_flag) { notify(''); }