From c7bc29635624984aee3e620680a264fd32b27e50 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 23 Dec 2020 19:13:25 +0200 Subject: feat! let server address be configured Instead of just specifying port, let the address (or name) be configured. --- subplot/server.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'subplot') diff --git a/subplot/server.py b/subplot/server.py index c4c01e1..7abe498 100644 --- a/subplot/server.py +++ b/subplot/server.py @@ -26,14 +26,19 @@ def start_chunk_server(ctx): chunks = "chunks" os.mkdir(chunks) - config = {"chunks": chunks, "tls_key": "test.key", "tls_cert": "test.pem"} - port = config["port"] = random.randint(2000, 30000) + port = random.randint(2000, 30000) + ctx["config"] = config = { + "chunks": chunks, + "tls_key": "test.key", + "tls_cert": "test.pem", + "address": f"localhost:{port}", + } + filename = "config.yaml" yaml.safe_dump(config, stream=open(filename, "w")) - logging.debug(f"Picked randomly port for obnam-server: {config['port']}") - ctx["config"] = config + logging.debug(f"Picked randomly port for obnam-server: {config['address']}") - ctx["server_url"] = f"https://localhost:{port}/chunks" + ctx["server_url"] = f"https://{config['address']}/chunks" start_daemon( ctx, -- cgit v1.2.1