summaryrefslogtreecommitdiff
path: root/update_daemon2.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-04-01 14:29:29 +0400
committerAndrew Dolgov <[email protected]>2013-04-01 14:29:29 +0400
commit4c2da349574869065a2014d775ef702f28c127a1 (patch)
treeee4ab56671447dd10016adc8402fc7517ef71deb /update_daemon2.php
parentdc5a8a21a88e1d13e3188cd4757b2c41471c70f7 (diff)
daemon2: check if schema version changed
Diffstat (limited to 'update_daemon2.php')
-rwxr-xr-xupdate_daemon2.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/update_daemon2.php b/update_daemon2.php
index fa64b302d..c87f0c10a 100755
--- a/update_daemon2.php
+++ b/update_daemon2.php
@@ -176,7 +176,9 @@
// 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);
@@ -193,6 +195,19 @@
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();