2017-05-02 2 views
1

J'essaie de déployer Django Channels sur Heroku en utilisant asgi avec mon implémentation wsgi existante. Puis-je déployer asgi et wsgi à heroku avec la configuration suivante?Déploiement d'asgi et de wsgi sur Heroku

Mon procfile:

web: gunicorn chatbot.wsgi --preload --log-file - 
daphne: daphne chat.asgi:channel_layer --port $PORT --bind 0.0.0.0 -v2 
chatworker: python manage.py runworker --settings=chat.settings -v2 

Mon fichier asgi.py:

import os 
from channels.asgi import get_channel_layer 

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "chat.settings") 

channel_layer = get_channel_layer() 

Mon fichier wsgi.py:

import os 

from django.core.wsgi import get_wsgi_application 
from whitenoise.django import DjangoWhiteNoise 

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "chat.settings") 

application = get_wsgi_application() 
application = DjangoWhiteNoise(application) 

Et mes couches canal dans settings.py:

CHANNEL_LAYERS = { 
    'default': { 
     "BACKEND": "asgi_redis.RedisChannelLayer", 
     "CONFIG": { 
      "hosts": [os.environ.get('REDIS_URL', 'redis://localhost:6379')] 
     }, 
     'ROUTING': 'chat.routing.channel_routing', 
    } 
} 

Répondre

1

Imaginé cela, au cas où cela pourrait être pertinent pour quelqu'un d'autre. Utiliser juste asgi était la meilleure solution. Mon procfile terminé être:

web: daphne chat.asgi:channel_layer --port $PORT --bind 0.0.0.0 -v2 
chatworker: python manage.py runworker --settings=chat.settings -v2 

En tant que solution pour servir des fichiers statiques, je mis à jour mon dossier routing.py d'inclure un StaticFileConsumer.

+0

Une idée de ce que '-v2' accomplit? –