From 2bc5732fd5cf51020db38762a6a10366c7b1fa67 Mon Sep 17 00:00:00 2001 From: Florian Kromer Date: Wed, 29 Nov 2023 11:38:22 +0100 Subject: [PATCH 1/2] override http_port and bind_address with SCRAPYD_HTTP_PORT and SCRAPYD_BIND_ADDRESS --- scrapyd/app.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scrapyd/app.py b/scrapyd/app.py index 4b784718..3a83d2b2 100644 --- a/scrapyd/app.py +++ b/scrapyd/app.py @@ -1,3 +1,4 @@ +import os import sys from scrapy.utils.misc import load_object @@ -36,7 +37,11 @@ def create_wrapped_resource(webcls, config, app): def application(config): app = Application("Scrapyd") http_port = config.getint('http_port', 6800) + if os.environ.get("SCRAPYD_HTTP_PORT"): + http_port = int(os.environ["SCRAPYD_HTTP_PORT"]) bind_address = config.get('bind_address', '127.0.0.1') + if os.environ.get("SCRAPYD_BIND_ADDRESS"): + bind_address = int(os.environ["SCRAPYD_BIND_ADDRESS"]) poll_interval = config.getfloat('poll_interval', 5) poller = QueuePoller(config) From 36383ef0d867d7be4dfcee7f4a831e0ea11d947b Mon Sep 17 00:00:00 2001 From: Florian Kromer Date: Wed, 29 Nov 2023 11:43:04 +0100 Subject: [PATCH 2/2] override username and password with SCRAPYD_USERNAME and SCRAPYD_PASSWORD --- scrapyd/app.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scrapyd/app.py b/scrapyd/app.py index 3a83d2b2..9f2c35f2 100644 --- a/scrapyd/app.py +++ b/scrapyd/app.py @@ -18,7 +18,11 @@ def create_wrapped_resource(webcls, config, app): username = config.get('username', '') + if os.environ.get("SCRAPYD_USERNAME"): + username = os.environ["SCRAPYD_USERNAME"] password = config.get('password', '') + if os.environ.get("SCRAPYD_PASSWORD"): + password = os.environ["SCRAPYD_PASSWORD"] if ':' in username: sys.exit("The `username` option contains illegal character ':', " "check and update the configuration file of Scrapyd")