mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-09-09 15:31:56 +00:00
Move start up DB checks to main data store.
This commit is contained in:
parent
d537be1ebd
commit
75f87450d8
@ -70,7 +70,7 @@ from synapse.rest.well_known import WellKnownResource
|
|||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage import DataStore
|
from synapse.storage import DataStore
|
||||||
from synapse.storage.engines import IncorrectDatabaseSetup, create_engine
|
from synapse.storage.engines import IncorrectDatabaseSetup, create_engine
|
||||||
from synapse.storage.prepare_database import UpgradeDatabaseException, prepare_database
|
from synapse.storage.prepare_database import UpgradeDatabaseException
|
||||||
from synapse.util.caches import CACHE_SIZE_FACTOR
|
from synapse.util.caches import CACHE_SIZE_FACTOR
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
from synapse.util.manhole import manhole
|
from synapse.util.manhole import manhole
|
||||||
@ -294,12 +294,6 @@ class SynapseHomeServer(HomeServer):
|
|||||||
else:
|
else:
|
||||||
logger.warning("Unrecognized listener type: %s", listener["type"])
|
logger.warning("Unrecognized listener type: %s", listener["type"])
|
||||||
|
|
||||||
def run_startup_checks(self, db_conn, database_engine):
|
|
||||||
try:
|
|
||||||
database_engine.check_database(db_conn.cursor())
|
|
||||||
except IncorrectDatabaseSetup as e:
|
|
||||||
quit_with_error(str(e))
|
|
||||||
|
|
||||||
|
|
||||||
# Gauges to expose monthly active user control metrics
|
# Gauges to expose monthly active user control metrics
|
||||||
current_mau_gauge = Gauge("synapse_admin_mau:current", "Current MAU")
|
current_mau_gauge = Gauge("synapse_admin_mau:current", "Current MAU")
|
||||||
@ -347,16 +341,12 @@ def setup(config_options):
|
|||||||
|
|
||||||
synapse.config.logger.setup_logging(hs, config, use_worker_options=False)
|
synapse.config.logger.setup_logging(hs, config, use_worker_options=False)
|
||||||
|
|
||||||
logger.info("Preparing database: %s...", config.database_config["name"])
|
logger.info("Setting up server")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with hs.get_db_conn(run_new_connection=False) as db_conn:
|
hs.setup()
|
||||||
prepare_database(db_conn, database_engine, config=config)
|
except IncorrectDatabaseSetup as e:
|
||||||
database_engine.on_new_connection(db_conn)
|
quit_with_error(str(e))
|
||||||
|
|
||||||
hs.run_startup_checks(db_conn, database_engine)
|
|
||||||
|
|
||||||
db_conn.commit()
|
|
||||||
except UpgradeDatabaseException:
|
except UpgradeDatabaseException:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"\nFailed to upgrade database.\n"
|
"\nFailed to upgrade database.\n"
|
||||||
@ -365,9 +355,6 @@ def setup(config_options):
|
|||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
logger.info("Database prepared in %s.", config.database_config["name"])
|
|
||||||
|
|
||||||
hs.setup()
|
|
||||||
hs.setup_master()
|
hs.setup_master()
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from synapse.storage.database import Database
|
from synapse.storage.database import Database
|
||||||
|
from synapse.storage.prepare_database import prepare_database
|
||||||
|
|
||||||
|
|
||||||
class DataStores(object):
|
class DataStores(object):
|
||||||
@ -26,4 +27,10 @@ class DataStores(object):
|
|||||||
# Note we pass in the main store here as workers use a different main
|
# Note we pass in the main store here as workers use a different main
|
||||||
# store.
|
# store.
|
||||||
database = Database(hs)
|
database = Database(hs)
|
||||||
|
|
||||||
|
# Check that db is correctly configured.
|
||||||
|
database.engine.check_database(db_conn.cursor())
|
||||||
|
|
||||||
|
prepare_database(db_conn, database.engine, config=hs.config)
|
||||||
|
|
||||||
self.main = main_store_class(database, db_conn, hs)
|
self.main = main_store_class(database, db_conn, hs)
|
||||||
|
Loading…
Reference in New Issue
Block a user