Skip to content
New issue

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

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

Already on GitHub? # to your account

--config doesn't work in GUNICORN_CMD_ARGS #1576

Closed
Code0x58 opened this issue Aug 24, 2017 · 3 comments
Closed

--config doesn't work in GUNICORN_CMD_ARGS #1576

Code0x58 opened this issue Aug 24, 2017 · 3 comments
Labels
help wanted Open for everyone. You do not need permission to work on these. May need familiarity with codebase. Improvement

Comments

@Code0x58
Copy link
Contributor

Specifying --config in the GUNICORN_CMD_ARGS environment variable quietly fails as config file loading only happens when it is passed as an argument:

def load_config(self):
# parse console args
parser = self.cfg.parser()
args = parser.parse_args()
# optional settings from apps
cfg = self.init(parser, args, args.args)
# Load up the any app specific configuration
if cfg and cfg is not None:
for k, v in cfg.items():
self.cfg.set(k.lower(), v)
if args.config:
self.load_config_from_file(args.config)
else:
default_config = get_default_config_file()
if default_config is not None:
self.load_config_from_file(default_config)
# Load up environment configuration
env_vars = self.cfg.get_cmd_args_from_env()
if env_vars:
env_args = parser.parse_args(env_vars)
for k, v in vars(env_args).items():
if v is None:
continue
if k == "args":
continue
self.cfg.set(k.lower(), v)
# Lastly, update the configuration with any command line
# settings.
for k, v in vars(args).items():
if v is None:
continue
if k == "args":
continue
self.cfg.set(k.lower(), v)

@tilgovi tilgovi added help wanted Open for everyone. You do not need permission to work on these. May need familiarity with codebase. Improvement labels Aug 28, 2017
@tilgovi
Copy link
Collaborator

tilgovi commented Aug 28, 2017

It looks like we parse the command options from the environment only after loading from a config file. We would have to parse these first, to get the config file option.

Good find.

@benoitc
Copy link
Owner

benoitc commented Sep 2, 2017

yeah the env should probably checked first and then the rest. At least it's seems to be the common pattern. Would you mind to provide a PR for it?

@Code0x58
Copy link
Contributor Author

Code0x58 commented Sep 2, 2017

Pull request #1581 submitted.

tilgovi added a commit that referenced this issue Sep 16, 2017
Fix #1576 - config file/module in GUNICORN_CMD_ARGS
mjjbell pushed a commit to mjjbell/gunicorn that referenced this issue Mar 16, 2018
mjjbell pushed a commit to mjjbell/gunicorn that referenced this issue Mar 16, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted Open for everyone. You do not need permission to work on these. May need familiarity with codebase. Improvement
Projects
None yet
Development

No branches or pull requests

3 participants