Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration via env vars #499

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions scrapyd/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys

from scrapy.utils.misc import load_object
Expand All @@ -17,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"]

Check warning on line 22 in scrapyd/app.py

View check run for this annotation

Codecov / codecov/patch

scrapyd/app.py#L22

Added line #L22 was not covered by tests
password = config.get('password', '')
if os.environ.get("SCRAPYD_PASSWORD"):
password = os.environ["SCRAPYD_PASSWORD"]

Check warning on line 25 in scrapyd/app.py

View check run for this annotation

Codecov / codecov/patch

scrapyd/app.py#L25

Added line #L25 was not covered by tests
if ':' in username:
sys.exit("The `username` option contains illegal character ':', "
"check and update the configuration file of Scrapyd")
Expand All @@ -36,7 +41,11 @@
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"])

Check warning on line 45 in scrapyd/app.py

View check run for this annotation

Codecov / codecov/patch

scrapyd/app.py#L45

Added line #L45 was not covered by tests
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"])

Check warning on line 48 in scrapyd/app.py

View check run for this annotation

Codecov / codecov/patch

scrapyd/app.py#L48

Added line #L48 was not covered by tests
poll_interval = config.getfloat('poll_interval', 5)

poller = QueuePoller(config)
Expand Down
Loading