Closed antct closed 5 years ago
Can you show how you are creating your application and parsing the CLI with argparse
?
Gunicorn calls parse_args
on its own instance of argparse
. You can implement a custom application that does something else, or you can ensure to mutate sys.argv
, or pass your own arguments to parse_args
, if you call it after Gunicorn starts.
https://docs.python.org/3/library/argparse.html#the-parse-args-method
Can you show how you are creating your application and parsing the CLI with
argparse
?Gunicorn calls
parse_args
on its own instance ofargparse
. You can implement a custom application that does something else, or you can ensure to mutatesys.argv
, or pass your own arguments toparse_args
, if you call it after Gunicorn starts.https://docs.python.org/3/library/argparse.html#the-parse-args-method
Thanks for your reply, I found if I use argparse module in my APP like args = parser.parse_args(sys.argv)
, the arguments of gunicorn may not work.
I try to replace it with args, unknown = parser.parse_known_args()
, everything goes well.
Thanks ~
Can the issue be closed, then? Do you need help to parse your own command line switches and the gunicorn switches together?
Thanks again!
I have a question How do I pass the env parameter through?
gunicorn -c gunicorn.conf.py app:app '/--env=prod/'
2023-03-09 10:04:32.438 | INFO | config.log_info:info:79 - args: Namespace(env='dev'), unknown: ['-c', 'gunicorn.conf.py', 'app:app', '/--env=prod/']
part of the code
from config.log_info import Logging
args, unknown = parser.parse_known_args()
Logging.info(f"args: {args}, unknown: {unknown}")
return vars(args)
I try to depoly my pytorch model with argparse module. It seems that the argparse module declared in the app will replace the arguments of gunicorn. And I have encountered such a problem like this:
The hints in the above section are the model parameters in the app. Thanks~