aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rpki/daemonize.py3
-rw-r--r--rpki/irdbd.py34
-rw-r--r--rpki/pubd.py32
-rw-r--r--rpki/rpkid.py31
4 files changed, 59 insertions, 41 deletions
diff --git a/rpki/daemonize.py b/rpki/daemonize.py
index 472d4b33..5a1c3979 100644
--- a/rpki/daemonize.py
+++ b/rpki/daemonize.py
@@ -97,7 +97,8 @@ def daemon(nochdir = False, noclose = False, pidfile = None):
try:
pid = os.fork()
except OSError, e:
- sys.exit("fork() failed: %d (%s)" % (e.errno, e.strerror))
+ logging.fatal("fork() failed: %d (%s)", e.errno, e.strerror)
+ sys.exit(1)
else:
if pid > 0:
os._exit(0) # pylint: disable=W0212
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):
diff --git a/rpki/pubd.py b/rpki/pubd.py
index 25c2b551..4d8962a7 100644
--- a/rpki/pubd.py
+++ b/rpki/pubd.py
@@ -75,21 +75,27 @@ class main(object):
rpki.log.init("pubd", args)
- self.cfg.set_global_flags()
+ try:
+ self.cfg.set_global_flags()
+
+ if not args.foreground:
+ rpki.daemonize.daemon(pidfile = args.pidfile)
+
+ if self.profile:
+ import cProfile
+ prof = cProfile.Profile()
+ try:
+ prof.runcall(self.main)
+ finally:
+ prof.dump_stats(self.profile)
+ logger.info("Dumped profile data to %s", self.profile)
+ else:
+ self.main()
- if not args.foreground:
- rpki.daemonize.daemon(pidfile = args.pidfile)
+ except:
+ logger.exception("Unandled exception in rpki.pubd.main()")
+ sys.exit(1)
- if self.profile:
- import cProfile
- prof = cProfile.Profile()
- try:
- prof.runcall(self.main)
- finally:
- prof.dump_stats(self.profile)
- logger.info("Dumped profile data to %s", self.profile)
- else:
- self.main()
def main(self):
diff --git a/rpki/rpkid.py b/rpki/rpkid.py
index af973b62..119de8ec 100644
--- a/rpki/rpkid.py
+++ b/rpki/rpkid.py
@@ -93,21 +93,26 @@ class main(object):
rpki.log.init("rpkid", args)
- self.cfg.set_global_flags()
+ try:
+ self.cfg.set_global_flags()
- if not args.foreground:
- rpki.daemonize.daemon(pidfile = args.pidfile)
+ if not args.foreground:
+ rpki.daemonize.daemon(pidfile = args.pidfile)
+
+ if self.profile:
+ import cProfile
+ prof = cProfile.Profile()
+ try:
+ prof.runcall(self.main)
+ finally:
+ prof.dump_stats(self.profile)
+ logger.info("Dumped profile data to %s", self.profile)
+ else:
+ self.main()
+ except:
+ logger.exception("Unandled exception in rpki.rpkid.main()")
+ sys.exit(1)
- if self.profile:
- import cProfile
- prof = cProfile.Profile()
- try:
- prof.runcall(self.main)
- finally:
- prof.dump_stats(self.profile)
- logger.info("Dumped profile data to %s", self.profile)
- else:
- self.main()
def main(self):