From 34e420fb088e236fc19e54ad947ebd4b55eae534 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 15 Mar 2007 05:57:24 +0100 Subject: add some more daemon debugging --- functions.php | 32 ++++++++++++++++++++++++++------ update_daemon.php | 18 +++++++++++++++--- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/functions.php b/functions.php index 5bcbfc1d7..ae663bb8a 100644 --- a/functions.php +++ b/functions.php @@ -363,7 +363,7 @@ } if (defined('DAEMON_EXTENDED_DEBUG')) { - print "update_rss_feed: start\n"; + _debug("update_rss_feed: start"); } $result = db_query($link, "SELECT update_interval,auth_login,auth_pass @@ -391,7 +391,7 @@ } if (defined('DAEMON_EXTENDED_DEBUG')) { - print "update_rss_feed: fetching...\n"; + _debug("update_rss_feed: fetching..."); } if (!defined('DAEMON_EXTENDED_DEBUG')) { @@ -401,7 +401,7 @@ $rss = fetch_rss($fetch_url); if (defined('DAEMON_EXTENDED_DEBUG')) { - print "update_rss_feed: fetch done, parsing...\n"; + _debug("update_rss_feed: fetch done, parsing..."); } else { error_reporting (DEFAULT_ERROR_LEVEL); } @@ -492,11 +492,15 @@ foreach ($iterator as $item) { $entry_guid = $item["id"]; - + if (!$entry_guid) $entry_guid = $item["guid"]; if (!$entry_guid) $entry_guid = $item["link"]; if (!$entry_guid) $entry_guid = make_guid_from_title($item["title"]); + if (defined('DAEMON_EXTENDED_DEBUG')) { + _debug("update_rss_feed: guid $entry_guid"); + } + if (!$entry_guid) continue; $entry_timestamp = ""; @@ -605,10 +609,18 @@ $entry_content = sanitize_rss($entry_content); + if (defined('DAEMON_EXTENDED_DEBUG')) { + _debug("update_rss_feed: done collecting data [TITLE:$entry_title]"); + } + db_query($link, "BEGIN"); if (db_num_rows($result) == 0) { + if (defined('DAEMON_EXTENDED_DEBUG')) { + _debug("update_rss_feed: base guid not found"); + } + // base post entry does not exist, create it $result = db_query($link, @@ -661,6 +673,10 @@ if (db_num_rows($result) == 1) { + if (defined('DAEMON_EXTENDED_DEBUG')) { + _debug("update_rss_feed: base guid found, creating user ref"); + } + // this will be used below in update handler $orig_content_hash = db_fetch_result($result, 0, "content_hash"); $orig_title = db_fetch_result($result, 0, "title"); @@ -764,6 +780,10 @@ db_query($link, "COMMIT"); + if (defined('DAEMON_EXTENDED_DEBUG')) { + _debug("update_rss_feed: looking for tags..."); + } + /* taaaags */ // , // @@ -857,7 +877,7 @@ } if (defined('DAEMON_EXTENDED_DEBUG')) { - print "update_rss_feed: done\n"; + _debug("update_rss_feed: done"); } } @@ -1938,7 +1958,7 @@ } function get_script_dt_add() { - if (strpos(VERSION, "99") === false) { + if (strpos(VERSION, ".99") === false) { return VERSION; } else { return time(); diff --git a/update_daemon.php b/update_daemon.php index f99e4f763..37c04e28f 100644 --- a/update_daemon.php +++ b/update_daemon.php @@ -3,13 +3,19 @@ // this daemon runs in the background and updates all feeds // continuously - define('DEFAULT_ERROR_LEVEL', E_ALL); + // define('DEFAULT_ERROR_LEVEL', E_ALL); + define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE); declare(ticks = 1); define('MAGPIE_CACHE_DIR', '/var/tmp/magpie-ttrss-cache-daemon'); define('DISABLE_SESSIONS', true); - define('DAEMON_EXTENDED_DEBUG', true); + + require_once "version.php"; + + if (strpos(VERSION, ".99") !== false) { + define('DAEMON_EXTENDED_DEBUG', true); + } define('PURGE_INTERVAL', 3600); // seconds @@ -25,14 +31,20 @@ require_once "functions.php"; require_once "magpierss/rss_fetch.inc"; - error_reporting(E_ALL); + error_reporting(DEFAULT_ERROR_LEVEL); function sigint_handler() { unlink("update_daemon.lock"); die("Received SIGINT. Exiting.\n"); } +// function sigalrm_handler() { +// print "SIGALARM\n"; +// pcntl_alarm(3); +// } + pcntl_signal(SIGINT, sigint_handler); +// pcntl_signal(SIGALRM, sigalrm_handler); $lock_handle = make_lockfile("update_daemon.lock"); -- cgit v1.2.3