summary refs log tree commit diff
path: root/synapse/app
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-28 13:39:42 +0100
committerErik Johnston <erik@matrix.org>2015-04-28 13:39:42 +0100
commit327ca883ec51780ea2a914d3c89ca0499f4656ac (patch)
treedc3f2c06cdbbfce8b1d1bb6a4db31a8852f5b43a /synapse/app
parentQuickly fix dodgy est. time remaining (diff)
parentMerge pull request #126 from matrix-org/csauth (diff)
downloadsynapse-327ca883ec51780ea2a914d3c89ca0499f4656ac.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into postgres
Diffstat (limited to 'synapse/app')
-rwxr-xr-xsynapse/app/homeserver.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index 110566e33f..43ce12af72 100755
--- a/synapse/app/homeserver.py
+++ b/synapse/app/homeserver.py
@@ -17,8 +17,11 @@
 import sys
 sys.dont_write_bytecode = True
 
-from synapse.storage import UpgradeDatabaseException
 from synapse.storage.engines import create_engine
+from synapse.storage import (
+    prepare_database, prepare_sqlite3_database, are_all_users_on_domain,
+    UpgradeDatabaseException,
+)
 
 from synapse.server import HomeServer
 
@@ -238,6 +241,21 @@ class SynapseHomeServer(HomeServer):
             )
             logger.info("Metrics now running on 127.0.0.1 port %d", config.metrics_port)
 
+    def run_startup_checks(self, db_conn, database_engine):
+        all_users_native = are_all_users_on_domain(
+            db_conn.cursor(), database_engine, self.hostname
+        )
+        if not all_users_native:
+            sys.stderr.write(
+                "\n"
+                "******************************************************\n"
+                "Found users in database not native to %s!\n"
+                "You cannot changed a synapse server_name after it's been configured\n"
+                "******************************************************\n"
+                "\n" % (self.hostname,)
+            )
+            sys.exit(1)
+
 
 def get_version_string():
     try:
@@ -382,6 +400,7 @@ def setup(config_options):
         )
 
         database_engine.prepare_database(db_conn)
+        hs.run_startup_checks(db_conn, database_engine)
 
         db_conn.commit()
     except UpgradeDatabaseException: