]> git.wh0rd.org - tt-rss.git/blobdiff - update_daemon2.php
rebase translations
[tt-rss.git] / update_daemon2.php
index e8523d22bd99c7a82f189812a1c86c265f0f0a4e..c87f0c10a60adcf7a69df11dd24ddb09756a4616 100755 (executable)
        // 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)) return;
+       if (!init_connection($link)) die("Can't initialize db connection.\n");
+
+       $schema_version = get_schema_version($link);
 
        db_close($link);
 
 
                if ($last_checkpoint + $spawn_interval < time()) {
 
+                       /* 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");
+                       $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");
+                               exit(100);
+                       }
+
                        check_ctimes();
                        reap_children();
 
 
                                        $nf = 0;
 
-                                       _debug("Waiting before update..");
-                                       sleep(rand(1,15));
+                                       _debug("Waiting before update [$j]..");
+                                       sleep($j*5);
                                        $nf = update_daemon_common($link);
 
                                        if (rand(0,100) > 50) {