diff options
author | Rob Austein <sra@hactrn.net> | 2016-04-24 22:37:11 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2016-04-24 22:37:11 +0000 |
commit | b648ba9b94382fe00850c0f0de2a47aa0974f5ea (patch) | |
tree | 5becf6d5bbda6802c0bfa3026f4a5bd97e1fc1e6 /rpki/irdbd.py | |
parent | 7c822bf648b175fc6c5727acd6468647772762c1 (diff) |
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
Diffstat (limited to 'rpki/irdbd.py')
-rw-r--r-- | rpki/irdbd.py | 34 |
1 files changed, 20 insertions, 14 deletions
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): |