From 586d9c0d3bad8420dc35e0822273692b25a6696c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 6 Sep 2018 12:19:39 +0200 Subject: [PATCH] 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. --- pillar/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pillar/__init__.py b/pillar/__init__.py index b412b7bf..7910d58a 100644 --- a/pillar/__init__.py +++ b/pillar/__init__.py @@ -140,8 +140,6 @@ class PillarServer(BlinkerCompatibleEve): 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 # disabled on all endpoints. More info at WTF_CSRF_CHECK_DEFAULT in config.py self.csrf = CSRFProtect(self) @@ -704,6 +702,8 @@ class PillarServer(BlinkerCompatibleEve): def finish_startup(self): self.log.info('Using MongoDB database %r', self.config['MONGO_DBNAME']) + with self.app_context(): + self.setup_db_indices() self._config_celery() api.setup_app(self)