Heroku打开报应用错误,gunicorn提示--log-file缺少参数问题求助
Gunicorn参数报错修复方案
根因说明
报错gunicorn: error: argument --error-logfile/--log-file: expected one argument由Procfile中gunicorn的日志参数写法兼容性问题导致:部分高版本gunicorn无法正确识别--log-file -中未加引号的-参数,会将其判定为参数缺失。
修复操作
方案一:移除冗余日志参数
Heroku默认会自动采集gunicorn输出的所有标准日志、错误日志,无需额外指定日志参数,直接将Procfile修改为如下内容即可:web: gunicorn pages_project.wsgi方案二:使用兼容写法保留日志配置
如果需要显式指定日志输出路径,将参数值用单引号包裹即可适配所有版本的gunicorn,修改后Procfile内容如下:web: gunicorn pages_project.wsgi --log-file '-'
修改完成后执行以下命令重新部署即可:
git add Procfile git commit -m "fix gunicorn log param" git push heroku main
部署完成后执行heroku restart重启应用,再运行heroku open即可正常访问。
验证方法
执行heroku logs --tail查看日志,无参数报错、且返回应用正常启动的相关日志即为修复成功。
内容的提问来源于stack exchange,提问作者fatbrokekid
相关产品推荐
相关产品推荐

