From 429adae788694f109174e35467c49d13b9533fe2 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sat, 13 Sep 2014 03:56:54 +0000 Subject: Groundwork for Django ORM world conquest: sort out settings.py mess. svn path=/branches/tk713/; revision=5948 --- rpki/irdbd.py | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'rpki/irdbd.py') diff --git a/rpki/irdbd.py b/rpki/irdbd.py index d53ae67c..856f91bf 100644 --- a/rpki/irdbd.py +++ b/rpki/irdbd.py @@ -166,7 +166,7 @@ class main(object): rpki.log.init("irdbd", args) - self.cfg = rpki.config.parser(args.config, "irdbd") + self.cfg = rpki.config.parser(set_filename = args.config, section = "irdbd") self.cfg.set_global_flags() if not args.foreground: @@ -185,34 +185,15 @@ class main(object): def main(self): - global rpki # pylint: disable=W0602 - from django.conf import settings - startup_msg = self.cfg.get("startup-message", "") if startup_msg: logger.info(startup_msg) - # Do -not- turn on DEBUG here except for short-lived tests, - # otherwise irdbd will eventually run out of memory and crash. - # - # If you must enable debugging, use django.db.reset_queries() to - # clear the query list manually, but it's probably better just to - # run with debugging disabled, since that's the expectation for - # production code. - # - # https://docs.djangoproject.com/en/dev/faq/models/#why-is-django-leaking-memory - - settings.configure( - DATABASES = { - "default" : { - "ENGINE" : "django.db.backends.mysql", - "NAME" : self.cfg.get("sql-database"), - "USER" : self.cfg.get("sql-username"), - "PASSWORD" : self.cfg.get("sql-password"), - "HOST" : "", - "PORT" : "" }}, - INSTALLED_APPS = ("rpki.irdb",),) + # Now that we know which configuration file to use, it's OK to + # load modules that require Django's settings module. + os.environ.update(DJANGO_SETTINGS_MODULE = "rpki.django_settings") + global rpki # pylint: disable=W0602 import rpki.irdb # pylint: disable=W0621 # Entirely too much fun with read-only access to transactional databases. -- cgit v1.2.3 From 558a82a19f6771ea264a9d7c56ec089b31643af1 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 14 Sep 2014 21:40:40 +0000 Subject: Remove --config arguments from all daemons, as part of simplifying startup procedure. This may be temporary, as processing --help without a configuration file may require deferring all Django imports until late enough that --config would work too. Defer for now. svn path=/branches/tk713/; revision=5953 --- rpki/irdbd.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'rpki/irdbd.py') diff --git a/rpki/irdbd.py b/rpki/irdbd.py index 856f91bf..64460c30 100644 --- a/rpki/irdbd.py +++ b/rpki/irdbd.py @@ -153,8 +153,6 @@ class main(object): time.tzset() parser = argparse.ArgumentParser(description = __doc__) - parser.add_argument("-c", "--config", - help = "override default location of configuration file") parser.add_argument("-f", "--foreground", action = "store_true", help = "do not daemonize") parser.add_argument("--pidfile", @@ -166,7 +164,7 @@ class main(object): rpki.log.init("irdbd", args) - self.cfg = rpki.config.parser(set_filename = args.config, section = "irdbd") + self.cfg = rpki.config.parser(section = "irdbd") self.cfg.set_global_flags() if not args.foreground: -- cgit v1.2.3