]> git.wh0rd.org - tt-rss.git/blobdiff - update_daemon2.php
more work on singleton-based DB
[tt-rss.git] / update_daemon2.php
index 37d6b40747adfc298c2dea96ab9162a7cc450d5b..6d13add0051135c4e65858184ba7ecfc13a11926 100755 (executable)
                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
        // 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
                        /* 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);
 
 
                                        $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
                                        _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);