aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrpkid/pubd.py42
-rwxr-xr-xrpkid/rpkid.py48
-rw-r--r--rpkid/testbed.py16
3 files changed, 71 insertions, 35 deletions
diff --git a/rpkid/pubd.py b/rpkid/pubd.py
index a96e75f0..36fd4a71 100755
--- a/rpkid/pubd.py
+++ b/rpkid/pubd.py
@@ -17,7 +17,9 @@
"""
RPKI publication engine.
-Usage: python pubd.py [ { -c | --config } configfile ] [ { -h | --help } ]
+Usage: python pubd.py [ { -c | --config } configfile ]
+ [ { -h | --help } ]
+ [ { -p | --profile } outputfile ]
Default configuration file is pubd.conf, override with --config option.
"""
@@ -99,26 +101,40 @@ time.tzset()
rpki.log.init("pubd")
cfg_file = "pubd.conf"
+profile = False
-opts,argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"])
+opts,argv = getopt.getopt(sys.argv[1:], "c:hp:?", ["config=", "help"])
for o,a in opts:
if o in ("-h", "--help", "-?"):
print __doc__
sys.exit(0)
- if o in ("-c", "--config"):
+ elif o in ("-c", "--config"):
cfg_file = a
+ elif o in ("-p", "--profile"):
+ profile = a
if argv:
raise RuntimeError, "Unexpected arguments %s" % argv
-cfg = rpki.config.parser(cfg_file, "pubd")
+def main():
-pctx = pubd_context(cfg)
+ cfg = rpki.config.parser(cfg_file, "pubd")
-rpki.https.server(
- dynamic_https_trust_anchor = pctx.build_https_ta_cache,
- host = pctx.https_server_host,
- port = pctx.https_server_port,
- server_key = pctx.pubd_key,
- server_cert = pctx.pubd_cert,
- handlers = (("/control", pctx.control_handler),
- ("/client/", pctx.client_handler)))
+ if profile:
+ rpki.log.info("Running in profile mode with output to %s" % profile)
+
+ pctx = pubd_context(cfg)
+
+ rpki.https.server(
+ dynamic_https_trust_anchor = pctx.build_https_ta_cache,
+ host = pctx.https_server_host,
+ port = pctx.https_server_port,
+ server_key = pctx.pubd_key,
+ server_cert = pctx.pubd_cert,
+ handlers = (("/control", pctx.control_handler),
+ ("/client/", pctx.client_handler)))
+
+if profile:
+ import cProfile
+ cProfile.run("main()", profile)
+else:
+ main()
diff --git a/rpkid/rpkid.py b/rpkid/rpkid.py
index 4b8fb998..67e3aed0 100755
--- a/rpkid/rpkid.py
+++ b/rpkid/rpkid.py
@@ -17,7 +17,9 @@
"""
RPKI engine daemon. This is still very much a work in progress.
-Usage: python rpkid.py [ { -c | --config } configfile ] [ { -h | --help } ]
+Usage: python rpkid.py [ { -c | --config } configfile ]
+ [ { -h | --help } ]
+ [ { -p | --profile } outputfile ]
Default configuration file is rpkid.conf, override with --config option.
"""
@@ -33,30 +35,44 @@ time.tzset()
rpki.log.init("rpkid")
cfg_file = "rpkid.conf"
+profile = None
-opts,argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"])
+opts,argv = getopt.getopt(sys.argv[1:], "c:hp:?", ["config=", "help", "profile="])
for o,a in opts:
if o in ("-h", "--help", "-?"):
print __doc__
sys.exit(0)
- if o in ("-c", "--config"):
+ elif o in ("-c", "--config"):
cfg_file = a
+ elif o in ("-p", "--profile"):
+ profile = a
if argv:
raise RuntimeError, "Unexpected arguments %s" % argv
-cfg = rpki.config.parser(cfg_file, "rpkid")
+def main():
-startup_msg = cfg.get("startup-message", "")
-if startup_msg:
- rpki.log.info(startup_msg)
+ cfg = rpki.config.parser(cfg_file, "rpkid")
-gctx = rpki.gctx.global_context(cfg)
+ startup_msg = cfg.get("startup-message", "")
+ if startup_msg:
+ rpki.log.info(startup_msg)
-rpki.https.server(host = gctx.https_server_host,
- port = gctx.https_server_port,
- server_key = gctx.rpkid_key,
- server_cert = gctx.rpkid_cert,
- dynamic_https_trust_anchor = gctx.build_https_ta_cache,
- handlers = (("/left-right", gctx.left_right_handler),
- ("/up-down/", gctx.up_down_handler),
- ("/cronjob", gctx.cronjob_handler)))
+ if profile:
+ rpki.log.info("Running in profile mode with output to %s" % profile)
+
+ gctx = rpki.gctx.global_context(cfg)
+
+ rpki.https.server(host = gctx.https_server_host,
+ port = gctx.https_server_port,
+ server_key = gctx.rpkid_key,
+ server_cert = gctx.rpkid_cert,
+ dynamic_https_trust_anchor = gctx.build_https_ta_cache,
+ handlers = (("/left-right", gctx.left_right_handler),
+ ("/up-down/", gctx.up_down_handler),
+ ("/cronjob", gctx.cronjob_handler)))
+
+if profile:
+ import cProfile
+ cProfile.run("main()", profile)
+else:
+ main()
diff --git a/rpkid/testbed.py b/rpkid/testbed.py
index b53604e8..6fc3aebe 100644
--- a/rpkid/testbed.py
+++ b/rpkid/testbed.py
@@ -18,9 +18,10 @@
Test framework to configure and drive a collection of rpkid.py and
irdbd.py instances under control of a master script.
-Usage: python rpkid.py [ { -c | --config } config_file ]
- [ { -h | --help } ]
- [ { -y | --yaml } yaml_script ]
+Usage: python testbed.py [ { -c | --config } config_file ]
+ [ { -h | --help } ]
+ [ { -p | --profile } ]
+ [ { -y | --yaml } yaml_script ]
Default config_file is testbed.conf, override with --config option.
@@ -43,14 +44,17 @@ time.tzset()
cfg_file = "testbed.conf"
yaml_script = None
+profile = False
-opts,argv = getopt.getopt(sys.argv[1:], "c:hy:?", ["config=", "help", "yaml="])
+opts,argv = getopt.getopt(sys.argv[1:], "c:hpy:?", ["config=", "help", "profile", "yaml="])
for o,a in opts:
if o in ("-h", "--help", "-?"):
print __doc__
sys.exit(0)
elif o in ("-c", "--config"):
cfg_file = a
+ elif o in ("-p", "--profile"):
+ profile = True
elif o in ("-y", "--yaml"):
yaml_script = a
if argv:
@@ -172,7 +176,7 @@ def main():
rootd_process = subprocess.Popen((prog_python, prog_rootd, "-c", rootd_name + ".conf"))
rpki.log.info("Starting pubd")
- pubd_process = subprocess.Popen((prog_python, prog_pubd, "-c", pubd_name + ".conf"))
+ pubd_process = subprocess.Popen((prog_python, prog_pubd, "-c", pubd_name + ".conf") + (("-p", pubd_name + ".prof") if profile else ()))
rpki.log.info("Starting rsyncd")
rsyncd_process = subprocess.Popen((prog_rsyncd, "--daemon", "--no-detach", "--config", rsyncd_name + ".conf"))
@@ -526,7 +530,7 @@ class allocation(object):
def run_daemons(self):
"""Run daemons for this entity."""
rpki.log.info("Running daemons for %s" % self.name)
- self.rpkid_process = subprocess.Popen((prog_python, prog_rpkid, "-c", self.name + ".conf"))
+ self.rpkid_process = subprocess.Popen((prog_python, prog_rpkid, "-c", self.name + ".conf") + (("-p", self.name + ".prof") if profile else ()))
self.irdbd_process = subprocess.Popen((prog_python, prog_irdbd, "-c", self.name + ".conf"))
def kill_daemons(self):