From 2b37c621509b97648544ce43418e7b88596cb8dc Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 27 Sep 2015 14:24:03 -0700 Subject: [PATCH] server: add -n/--no-daemon, to run on py3 The twisted.python.logfile in Twisted-15.4.0 is not yet compatible with py3, but can be bypassed by not daemonizing the server (so it doesn't write to a logfile). This has been fixed in twisted trunk, so when 15.4.1 or 15.5.0 comes out, this will no longer be needed. But I think we'll leave it in place, since sometimes it's handy to run a server without daemonization. --- src/wormhole/scripts/runner.py | 1 + src/wormhole/servers/cmd_server.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wormhole/scripts/runner.py b/src/wormhole/scripts/runner.py index 044fd8b..c395dea 100644 --- a/src/wormhole/scripts/runner.py +++ b/src/wormhole/scripts/runner.py @@ -40,6 +40,7 @@ sp_start.add_argument("--transit", default="tcp:3001", metavar="tcp:PORT", help="endpoint specification for the transit-relay port") sp_start.add_argument("--advertise-version", metavar="VERSION", help="version to recommend to clients") +sp_start.add_argument("-n", "--no-daemon", action="store_true") #sp_start.add_argument("twistd_args", nargs="*", default=None, # metavar="[TWISTD-ARGS..]", # help=dedent("""\ diff --git a/src/wormhole/servers/cmd_server.py b/src/wormhole/servers/cmd_server.py index b7864ad..3f4c0cb 100644 --- a/src/wormhole/servers/cmd_server.py +++ b/src/wormhole/servers/cmd_server.py @@ -22,8 +22,11 @@ def start_server(args): c = MyTwistdConfig() #twistd_args = tuple(args.twistd_args) + ("XYZ",) - twistd_args = ("XYZ",) # TODO: allow user to add twistd-specific args - c.parseOptions(twistd_args) + base_args = [] + if args.no_daemon: + base_args.append("--nodaemon") + twistd_args = base_args + ["XYZ"] + c.parseOptions(tuple(twistd_args)) c.loadedPlugins = {"XYZ": MyPlugin(args)} print("starting wormhole relay server")