Take cli args for db and stats paths
This commit is contained in:
parent
777d722b0d
commit
6b20cb760a
|
@ -22,6 +22,15 @@ def server(ctx): # this is the setuptools entrypoint for bin/wormhole-server
|
||||||
ctx.obj = Config()
|
ctx.obj = Config()
|
||||||
|
|
||||||
|
|
||||||
|
_relay_database_path = click.option(
|
||||||
|
"--relay-database-path", default="relay.sqlite", metavar="PATH",
|
||||||
|
help="location for the relay server state database",
|
||||||
|
)
|
||||||
|
_stats_json_path = click.option(
|
||||||
|
"--stats-json-path", default="stats.json", metavar="PATH",
|
||||||
|
help="location to write the relay stats file",
|
||||||
|
)
|
||||||
|
|
||||||
@server.command()
|
@server.command()
|
||||||
@click.option(
|
@click.option(
|
||||||
"--rendezvous", default="tcp:4000", metavar="tcp:PORT",
|
"--rendezvous", default="tcp:4000", metavar="tcp:PORT",
|
||||||
|
@ -52,9 +61,13 @@ def server(ctx): # this is the setuptools entrypoint for bin/wormhole-server
|
||||||
"--disallow-list", is_flag=True,
|
"--disallow-list", is_flag=True,
|
||||||
help="never send list of allocated nameplates",
|
help="never send list of allocated nameplates",
|
||||||
)
|
)
|
||||||
|
@_relay_database_path
|
||||||
|
@_stats_json_path
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
def start(cfg, signal_error, no_daemon, blur_usage, advertise_version,
|
def start(cfg, signal_error, no_daemon, blur_usage, advertise_version,
|
||||||
transit, rendezvous, disallow_list):
|
transit, rendezvous, disallow_list, relay_database_path,
|
||||||
|
stats_json_path,
|
||||||
|
):
|
||||||
"""
|
"""
|
||||||
Start a relay server
|
Start a relay server
|
||||||
"""
|
"""
|
||||||
|
@ -66,6 +79,8 @@ def start(cfg, signal_error, no_daemon, blur_usage, advertise_version,
|
||||||
cfg.rendezvous = str(rendezvous)
|
cfg.rendezvous = str(rendezvous)
|
||||||
cfg.signal_error = signal_error
|
cfg.signal_error = signal_error
|
||||||
cfg.allow_list = not disallow_list
|
cfg.allow_list = not disallow_list
|
||||||
|
cfg.relay_database_path = relay_database_path
|
||||||
|
cfg.stats_json_path = stats_json_path
|
||||||
|
|
||||||
start_server(cfg)
|
start_server(cfg)
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@ class MyPlugin(object):
|
||||||
self.args.rendezvous,
|
self.args.rendezvous,
|
||||||
self.args.transit,
|
self.args.transit,
|
||||||
self.args.advertise_version,
|
self.args.advertise_version,
|
||||||
"relay.sqlite",
|
self.args.relay_database_path,
|
||||||
self.args.blur_usage,
|
self.args.blur_usage,
|
||||||
signal_error=self.args.signal_error,
|
signal_error=self.args.signal_error,
|
||||||
stats_file="stats.json",
|
stats_file=self.args.stats_json_path,
|
||||||
allow_list=self.args.allow_list,
|
allow_list=self.args.allow_list,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ class RelayServer(service.MultiService):
|
||||||
service.MultiService.__init__(self)
|
service.MultiService.__init__(self)
|
||||||
self._blur_usage = blur_usage
|
self._blur_usage = blur_usage
|
||||||
self._allow_list = allow_list
|
self._allow_list = allow_list
|
||||||
|
self._db_url = db_url
|
||||||
|
|
||||||
db = get_db(db_url)
|
db = get_db(db_url)
|
||||||
welcome = {
|
welcome = {
|
||||||
|
|
|
@ -1180,6 +1180,10 @@ class FakeConfig(object):
|
||||||
rendezvous = str('tcp:1234')
|
rendezvous = str('tcp:1234')
|
||||||
signal_error = True
|
signal_error = True
|
||||||
allow_list = False
|
allow_list = False
|
||||||
|
relay_database_path = "relay.sqlite"
|
||||||
|
stats_json_path = "stats.json"
|
||||||
|
|
||||||
|
|
||||||
class Server(unittest.TestCase):
|
class Server(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -1210,3 +1214,9 @@ class Server(unittest.TestCase):
|
||||||
cfg = fake_start_reserver.mock_calls[0][1][0]
|
cfg = fake_start_reserver.mock_calls[0][1][0]
|
||||||
MyPlugin(cfg).makeService(None)
|
MyPlugin(cfg).makeService(None)
|
||||||
|
|
||||||
|
def test_state_locations(self):
|
||||||
|
cfg = FakeConfig()
|
||||||
|
plugin = MyPlugin(cfg)
|
||||||
|
relay = plugin.makeService(None)
|
||||||
|
self.assertEqual('relay.sqlite', relay._db_url)
|
||||||
|
self.assertEqual('stats.json', relay._stats_file)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user