aboutsummaryrefslogtreecommitdiff
path: root/rpkid
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2012-07-25 23:49:21 +0000
committerRob Austein <sra@hactrn.net>2012-07-25 23:49:21 +0000
commit232f670a7a8109f4a29356ed98aaa7e23a082bb8 (patch)
treea5b7d98871361117feacb9faf9a81715a31fe569 /rpkid
parentc4f104ae55846310d70aa913885607195489f09b (diff)
Add profiling support.
svn path=/trunk/; revision=4608
Diffstat (limited to 'rpkid')
-rw-r--r--rpkid/rpki/irdbd.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/rpkid/rpki/irdbd.py b/rpkid/rpki/irdbd.py
index ae250085..60f6a549 100644
--- a/rpkid/rpki/irdbd.py
+++ b/rpkid/rpki/irdbd.py
@@ -138,15 +138,16 @@ class main(object):
def __init__(self, **kwargs):
global rpki
- from django.conf import settings
os.environ["TZ"] = "UTC"
time.tzset()
cfg_file = None
foreground = False
-
- opts, argv = getopt.getopt(sys.argv[1:], "c:dfh?", ["config=", "debug", "foreground", "help"])
+ profile = None
+
+ opts, argv = getopt.getopt(sys.argv[1:], "c:dfhp:?",
+ ["config=", "debug", "foreground", "help", "profile="])
for o, a in opts:
if o in ("-h", "--help", "-?"):
print __doc__
@@ -158,18 +159,31 @@ class main(object):
foreground = True
elif o in ("-f", "--foreground"):
foreground = True
+ elif o in ("-p", "--profile"):
+ profile = a
if argv:
raise rpki.exceptions.CommandParseFailure("Unexpected arguments %s" % argv)
rpki.log.init("irdbd")
- cfg = rpki.config.parser(cfg_file, "irdbd")
- cfg.set_global_flags()
+ self.cfg = rpki.config.parser(cfg_file, "irdbd")
+ self.cfg.set_global_flags()
if not foreground:
rpki.daemonize.daemon()
- startup_msg = cfg.get("startup-message", "")
+ if profile:
+ import cProfile
+ cProfile.run("self.main()", profile)
+ else:
+ self.main()
+
+ def main(self):
+
+ global rpki
+ from django.conf import settings
+
+ startup_msg = self.cfg.get("startup-message", "")
if startup_msg:
rpki.log.info(startup_msg)
@@ -187,9 +201,9 @@ class main(object):
DATABASES = {
"default" : {
"ENGINE" : "django.db.backends.mysql",
- "NAME" : cfg.get("sql-database"),
- "USER" : cfg.get("sql-username"),
- "PASSWORD" : cfg.get("sql-password"),
+ "NAME" : self.cfg.get("sql-database"),
+ "USER" : self.cfg.get("sql-username"),
+ "PASSWORD" : self.cfg.get("sql-password"),
"HOST" : "",
"PORT" : "" }},
INSTALLED_APPS = ("rpki.irdb",),)
@@ -223,7 +237,7 @@ class main(object):
rpki.left_right.list_roa_requests_elt : self.handle_list_roa_requests,
rpki.left_right.list_ghostbuster_requests_elt : self.handle_list_ghostbuster_requests }
- u = urlparse.urlparse(cfg.get("http-url"))
+ u = urlparse.urlparse(self.cfg.get("http-url"))
assert u.scheme in ("", "http") and \
u.username is None and \