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

--config doesn't work in GUNICORN_CMD_ARGS #1576

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

Comments

Projects
None yet
3 participants
@Code0x58
Contributor

Code0x58 commented Aug 24, 2017

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Contributor

Code0x58 commented Sep 2, 2017

Pull request #1581 submitted.

@tilgovi tilgovi closed this in 6a2a8b3 Sep 16, 2017

tilgovi added a commit that referenced this issue Sep 16, 2017

Merge pull request #1581 from Code0x58/fix/1576-env-config-file
Fix #1576 - config file/module in GUNICORN_CMD_ARGS

fofanov pushed a commit to fofanov/gunicorn that referenced this issue Mar 16, 2018

fofanov pushed a commit to fofanov/gunicorn that referenced this issue Mar 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment