问题描述
我已经在这个问题上待了几个小时,请有人帮忙。 谢谢您的宝贵时间,谢谢。
我一直试图发布使用Django Channels进行Websocket支持的DRF应用程序。我现在只想将其用于进一步的开发,因此考虑将其部署到Heroku。但是Heroku一直给我这个 Push Rejected 错误。
应用程序结构(部分):
AppBAckend----
|--AppBackend
|--settings.py
|--routing.py
|--asgi.py
|--chat
--manage.py
--requirements.txt
--procfile
在settings.py中:
# Development
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels.layers.InMemoryChannelLayer"
}
}
在routing.py中:
# imports
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter,URLRouter
import chat
application = ProtocolTypeRouter({
# (http->django views is added by default)
'websocket': AuthMiddlewareStack(
URLRouter(
chat.routing.websocket_urlpatterns
)
),})
channel_routing = {}
在asgi.py中:
import django
import os
from channels.routing import get_default_application
from channels.layers import get_channel_layer
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE','AppBackend.settings')
# application = get_asgi_application()
django.setup()
application = get_default_application()
channel_layer = get_channel_layer()
(Heroku)程序文件:
web: gunicorn AppBackend.wsgi --log-file -
web2: daphne AppBackend.asgi:application --port $PORT --bind 0.0.0.0 -v2
worker: python manage.py runworker channel_layer -v2
chatworker: python manage.py runworker --settings=AppBackend.settings.production -v2
(Heroku)requirements.txt:
django
gunicorn
django-heroku
channels
djangorestframework
(Heroku)runtime.txt:
python-3.7.8
(Heroku)错误消息:
(django-env) D:\Code\Projects\social-media-app-backend\AppBackend>git push heroku master
Enumerating objects: 2874,done.
Counting objects: 100% (2874/2874),done.
Delta compression using up to 12 threads
Compressing objects: 100% (2861/2861),done.
Writing objects: 100% (2874/2874),12.81 MiB | 210.00 KiB/s,done.
Total 2874 (delta 253),reused 0 (delta 0),pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push Failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to fierce-bayou-52758.
remote:
To https://git.heroku.com/fierce-bayou-52758.git
! [remote rejected] master -> master (pre-receive hook declined)
error: Failed to push some refs to 'https://git.heroku.com/fierce-bayou-52758.git'
再次感谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)