def sanity_check(self): """Perform post-initialization sanity checks. This is run on every startup to check that the database table schema matches our model definitions. If there are un-run migrations this will bail out and do not let the problem to escalate later. See also: :ref:`websauna.sanity_check`. """ import sqlalchemy.exc from websauna.system.model import sanitycheck from websauna.system.model.meta import Base from websauna.system.model.meta import create_dbsession from websauna.system.core import redis dbsession = create_dbsession(self.config.registry) db_connection_string = self.config.registry.settings.get( "sqlalchemy.url") try: if not sanitycheck.is_sane_database(Base, dbsession): raise SanityCheckFailed( "The database sanity check failed. Check log for details.") except sqlalchemy.exc.OperationalError as e: raise SanityCheckFailed( "The database {} is not responding.\nMake sure the database is running on your local computer or correctly configured in settings INI file.\nFor more information see https://websauna.org/docs/tutorials/gettingstarted/tutorial_02.html." .format(db_connection_string)) from e dbsession.close() if self._has_redis_sessions: if not redis.is_sane_redis(self.config): raise SanityCheckFailed( "Could not connect to Redis server.\nWebsauna is configured to use Redis server for session data.\nIt cannot start up without a running Redis server.\nPlease consult your operating system community how to install and start a Redis server." )
def sanity_check(self): """Perform post-initialization sanity checks. This is run on every startup to check that the database table schema matches our model definitions. If there are un-run migrations this will bail out and do not let the problem to escalate later. See also: :ref:`websauna.sanity_check`. """ from websauna.system.model import sanitycheck from websauna.system.model.meta import Base from websauna.system.model.meta import create_dbsession from websauna.system.core import redis dbsession = create_dbsession(self.config.registry) if not sanitycheck.is_sane_database(Base, dbsession): raise SanityCheckFailed( "The database sanity check failed. Check log for details.") dbsession.close() if self._has_redis_sessions: if not redis.is_sane_redis(self.config): raise SanityCheckFailed( "Could not connect to Redis server.\nWebsauna is configured to use Redis server for session data.\nIt cannot start up without a running Redis server.\nPlease consult your operating system community how to install and start a Redis server." )
def sanity_check(self): """Perform post-initialization sanity checks. This is run on every startup to check that the database table schema matches our model definitions. If there are un-run migrations this will bail out and do not let the problem to escalate later. See also: :ref:`websauna.sanity_check`. """ import sqlalchemy.exc from websauna.system.model import sanitycheck from websauna.system.model.meta import Base from websauna.system.model.meta import create_dbsession from websauna.system.core import redis dbsession = create_dbsession(self.config.registry) db_connection_string = self.config.registry.settings.get("sqlalchemy.url") try: if not sanitycheck.is_sane_database(Base, dbsession): raise SanityCheckFailed("The database sanity check failed. Check log for details.") except sqlalchemy.exc.OperationalError as e: raise SanityCheckFailed("The database {} is not responding. Make sure the database is running on your local computer or correctly configured in settings INI file. For more information see https://websauna.org/docs/tutorials/gettingstarted/tutorial_02.html.".format(db_connection_stringg)) from e dbsession.close() if self._has_redis_sessions: if not redis.is_sane_redis(self.config): raise SanityCheckFailed("Could not connect to Redis server.\nWebsauna is configured to use Redis server for session data.\nIt cannot start up without a running Redis server.\nPlease consult your operating system community how to install and start a Redis server.")
def sanity_check(self): """Perform post-initialization sanity checks. This is run on every startup to check that the database table schema matches our model definitions. If there are un-run migrations this will bail out and do not let the problem to escalate later. """ from websauna.system.model import sanitycheck from websauna.system.model.meta import Base from websauna.system.model.meta import create_dbsession from websauna.system.core import redis dbsession = create_dbsession(self.config.registry) if not sanitycheck.is_sane_database(Base, dbsession): raise SanityCheckFailed("The database sanity check failed. Check log for details.") dbsession.close() if self._has_redis_sessions: if not redis.is_sane_redis(self.config): raise SanityCheckFailed("Could not connect to Redis server.\nWebsauna is configured to use Redis server for session data.\nIt cannot start up without a running Redis server.\nPlease consult your operating system community how to install and start a Redis server.")