From b648ba9b94382fe00850c0f0de2a47aa0974f5ea Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 24 Apr 2016 22:37:11 +0000 Subject: Add exception handler of last resort to servers, in an attempt to get startup error messages logged properly if at all possible. See #806. svn path=/branches/tk705/; revision=6387 --- rpki/irdbd.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'rpki/irdbd.py') diff --git a/rpki/irdbd.py b/rpki/irdbd.py index 270b4f9f..adc24a00 100644 --- a/rpki/irdbd.py +++ b/rpki/irdbd.py @@ -165,23 +165,29 @@ class main(object): rpki.log.init("irdbd", args) - self.cfg.set_global_flags() + try: + self.cfg.set_global_flags() - self.cms_timestamp = None + self.cms_timestamp = None - if not args.foreground: - rpki.daemonize.daemon(pidfile = args.pidfile) + if not args.foreground: + rpki.daemonize.daemon(pidfile = args.pidfile) + + if args.profile: + import cProfile + prof = cProfile.Profile() + try: + prof.runcall(self.main) + finally: + prof.dump_stats(args.profile) + logger.info("Dumped profile data to %s", args.profile) + else: + self.main() + + except: + logger.exception("Unandled exception in rpki.irdbd.main()") + sys.exit(1) - if args.profile: - import cProfile - prof = cProfile.Profile() - try: - prof.runcall(self.main) - finally: - prof.dump_stats(args.profile) - logger.info("Dumped profile data to %s", args.profile) - else: - self.main() def main(self): -- cgit v1.2.3