Create MongoDB indices at Pillar startup, and not at first request

This makes things a little more predictable, and allowed me to actually
find & fix a bug in a unittest.
This commit is contained in:
Sybren A. Stüvel 2018-09-06 12:19:39 +02:00
parent ac23c7b00b
commit 586d9c0d3b

View File

@ -140,8 +140,6 @@ class PillarServer(BlinkerCompatibleEve):
self.org_manager = pillar.api.organizations.OrgManager() self.org_manager = pillar.api.organizations.OrgManager()
self.before_first_request(self.setup_db_indices)
# Make CSRF protection available to the application. By default it is # Make CSRF protection available to the application. By default it is
# disabled on all endpoints. More info at WTF_CSRF_CHECK_DEFAULT in config.py # disabled on all endpoints. More info at WTF_CSRF_CHECK_DEFAULT in config.py
self.csrf = CSRFProtect(self) self.csrf = CSRFProtect(self)
@ -704,6 +702,8 @@ class PillarServer(BlinkerCompatibleEve):
def finish_startup(self): def finish_startup(self):
self.log.info('Using MongoDB database %r', self.config['MONGO_DBNAME']) self.log.info('Using MongoDB database %r', self.config['MONGO_DBNAME'])
with self.app_context():
self.setup_db_indices()
self._config_celery() self._config_celery()
api.setup_app(self) api.setup_app(self)