Python gunicorn worker 因参数不正确而退出?

Python gunicorn worker exiting due to incorrect arguments?

我正在设置一个新服务器,并且作为该过程的一部分,我设置了 gunicorn 来为 Web 文件提供服务。但是,在传输数据时,在旧服务器上运行的命令在该服务器上不起作用。

gunicorn master 进程似乎启动了 workers,但由于 "unrecognized arguments",workers 立即退出。命令是:/home/postgres/venv/bin/gunicorn [app]:app。这与之前的服务器相同,除了该服务器使用的是 virtualenv 而不是全局包。我怀疑这可能是问题所在,但我不确定为什么或如何修复它。

相同 Python 版本,但 gunicorn 版本更新(旧版本为 19.4.5,新版本为 19.9.0)。

我已将应用名称替换为 [app] 以防止混淆,但名称中没有无效字符或任何内容。

日志:

root@ns500738:/home/postgres/[app]# /home/postgres/venv/bin/gunicorn [app]:app
[2018-07-18 13:27:56 -0400] [10080] [INFO] Starting gunicorn 19.9.0
[2018-07-18 13:27:56 -0400] [10080] [INFO] Listening at: http://127.0.0.1:8000 (10080)
[2018-07-18 13:27:56 -0400] [10080] [INFO] Using worker: sync
[2018-07-18 13:27:56 -0400] [10083] [INFO] Booting worker with pid: 10083
usage: gunicorn [-h] [-c]
gunicorn: error: unrecognized arguments: [app]:app
[2018-07-18 13:27:56 -0400] [10083] [INFO] Worker exiting (pid: 10083)
[2018-07-18 13:27:56 -0400] [10085] [INFO] Booting worker with pid: 10085
usage: gunicorn [-h] [-c]
gunicorn: error: unrecognized arguments: [app]:app
[2018-07-18 13:27:57 -0400] [10085] [INFO] Worker exiting (pid: 10085)
[2018-07-18 13:27:57 -0400] [10087] [INFO] Booting worker with pid: 10087
usage: gunicorn [-h] [-c]
gunicorn: error: unrecognized arguments: [app]:app
[2018-07-18 13:27:57 -0400] [10087] [INFO] Worker exiting (pid: 10087)
^C[2018-07-18 13:27:57 -0400] [10080] [INFO] Handling signal: int
[2018-07-18 13:27:57 -0400] [10080] [INFO] Shutting down: Master

我想通了。

我最近向脚本添加了 argparse 参数解析,这导致它捕获了要传递给 gunicorn 的参数。

如果我删除 argparse 部分,它会再次工作。