X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=update_daemon2.php;h=6d13add0051135c4e65858184ba7ecfc13a11926;hb=aca75cb5cb323535099c7aef46a78ea3cec082f2;hp=2fbdd8b8cde7db3b68be98c91ce6fe812d967b93;hpb=ec25336d6a1a0f276200e2ddc33f592fcf0ab530;p=tt-rss.git diff --git a/update_daemon2.php b/update_daemon2.php index 2fbdd8b8..6d13add0 100755 --- a/update_daemon2.php +++ b/update_daemon2.php @@ -14,12 +14,14 @@ define('DAEMON_EXTENDED_DEBUG', true); } + require_once "autoload.php"; require_once "functions.php"; require_once "rssfuncs.php"; require_once "sanity_check.php"; require_once "config.php"; require_once "db.php"; require_once "db-prefs.php"; + require_once "errorhandler.php"; // defaults define('PURGE_INTERVAL', 3600); // seconds @@ -176,12 +178,16 @@ // It is unnecessary to start the fork loop if database is not ok. $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - if (!init_connection($link)) die("Can't initialize db connection.\n"); + if (!init_plugins($link)) die("Can't initialize db connection.\n"); $schema_version = get_schema_version($link); db_close($link); + if ($schema_version != SCHEMA_VERSION) { + die("Schema version is wrong, please upgrade the database.\n"); + } + while (true) { // Since sleep is interupted by SIGCHLD, we need another way to @@ -198,13 +204,13 @@ /* Check if schema version changed */ $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - if (!init_connection($link)) die("Can't initialize db connection.\n"); + if (!init_plugins($link)) die("Can't initialize db connection.\n"); $test_schema_version = get_schema_version($link); db_close($link); if ($test_schema_version != $schema_version) { - _debug("Expected schema version: $schema_version, got: $test_schema_version"); - _debug("Schema version changed while we were running, bailing out"); + echo "Expected schema version: $schema_version, got: $test_schema_version\n"; + echo "Schema version changed while we were running, bailing out\n"; exit(100); } @@ -250,7 +256,7 @@ $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - if (!init_connection($link)) return; + if (!init_plugins($link)) return; // We disable stamp file, since it is of no use in a multiprocess update. // not really, tho for the time being -fox @@ -284,7 +290,11 @@ _debug("Elapsed time: " . (time() - $start_timestamp) . " second(s)"); if ($nf > 0) { - _debug("Feeds processed: $nf; feeds/minute: " . sprintf("%.2d", $nf/((time()-$start_timestamp)/60))); + _debug("Feeds processed: $nf"); + + if (time() - $start_timestamp > 0) { + _debug("Feeds/minute: " . sprintf("%.2d", $nf/((time()-$start_timestamp)/60))); + } } db_close($link);