Closed VikashKothary closed 3 years ago
I'd say configuring everything via environment variables may make it a little more difficult to develop. With all settings written in settings file you just pull code and everyone can jump and start working on it. With environment variables, you have to share it with other developers somehow, you have to maintain some configuration for people. So, I'd say it is better to keep it simple, like it is now. You can always add configuration from environment in docker easily, it won't be a serious problem.
Hi @pawelmhm, thank you for the time.
Like I mentioned, it's not a problem for me since I already use the above for a workaround and my goal was mainly to share this with other people might be interested in solving the same problem I did.
I understand if you think it's out-of-the-scope for the library but I wanted to clarify a few things if this ever comes up in the future.
.env
for development
configuring everything via environment variables may make it a little more difficult to develop
.env
files are typically used for development. They list all the environment variables and are ignored from the codebaseyou just pull code and everyone can jump and start working on it
you have to share it with other developers somehow
.settings
fileadd configuration from environment in docker
.env
out-of-the-box.
Why
Configuration using environment variables is very popular. This is especially useful when running an application in Docker.
This isn't a major issue since we can technically use environment variables to configure Scrapyrt. But personally I think it would be cool to have it out-of-the-box.
Worse-case this will document how I did it and might help someone else who wanted to do this.
How
This is how I do it currently. I run:
where
scrapyrt.settings
points to my scrapy spider's settings file:What
My understanding is if the above change was made to the
default_settings.py
then this will be available out-of-the-box. Which might be a nice feature to have.Host and Port can potentially be set here as the defaults assuming you want CLI to override environment variables.
P.S My 2 cents is that Host and Port should also be configurable in
settings.py
. If you're happy to have this change, then this could be a good time to make that change.