admin 管理员组文章数量: 1086019
I'm trying to deploy my Django application with Heroku (on Windows), and using Waitress (because Gunicorn no longer runs on Windows??). When I hard coded the PORT number, I was able to run it fine.
When I try to define PORT in the Procfile as an environment variable
Procfile:
web: waitress-serve --port=$PORT [projectname].wsgi:application
from .env
WEB_CONCURRENCY=2
PORT=$PORT
from settings.py
import environ
from environ import Env
env = Env()
...
PORT = env('PORT')
running "heroku local" produces
ValueError: invalid literal for int() with base 10: '$PORT'
Ultimately I'm trying to resolve a failure to bind to PORT:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT `within 60 seconds of launch`
I keep seeing mention that "$PORT" is not appropriate for Windows. However I can't figure out what I'm missing. I've seen suggestions that "%PORT%" would work for Windows, but I haven't had success. I've also tried "PORT" without symbols (as the Waitress docs seem to suggest). If there is a Windows friendly syntax, would I need to use it in both .env and Procfile?
I'm trying to deploy my Django application with Heroku (on Windows), and using Waitress (because Gunicorn no longer runs on Windows??). When I hard coded the PORT number, I was able to run it fine.
When I try to define PORT in the Procfile as an environment variable
Procfile:
web: waitress-serve --port=$PORT [projectname].wsgi:application
from .env
WEB_CONCURRENCY=2
PORT=$PORT
from settings.py
import environ
from environ import Env
env = Env()
...
PORT = env('PORT')
running "heroku local" produces
ValueError: invalid literal for int() with base 10: '$PORT'
Ultimately I'm trying to resolve a failure to bind to PORT:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT `within 60 seconds of launch`
I keep seeing mention that "$PORT" is not appropriate for Windows. However I can't figure out what I'm missing. I've seen suggestions that "%PORT%" would work for Windows, but I haven't had success. I've also tried "PORT" without symbols (as the Waitress docs seem to suggest). If there is a Windows friendly syntax, would I need to use it in both .env and Procfile?
Share Improve this question edited Mar 30 at 0:39 relp lamfred asked Mar 29 at 22:34 relp lamfredrelp lamfred 111 bronze badge1 Answer
Reset to default 0Explicitly tell you django-environs library that you are passing int not string. You can achieve that by casting the value in this format, so update your code on settings.py to look like this;
Remove the dollar sign ($) on your .env as well. Then rerun your build process.
PORT = env.int("PORT")
本文标签: pythonTrouble setting PORT in DjangoHeroku Procfile using WaitressStack Overflow
版权声明:本文标题:python - Trouble setting PORT in DjangoHeroku Procfile using Waitress - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744002139a2516641.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论