Django asgi/channels not deploying
i have a django asgi project which gives me error whenever i try to deplo it o railway. Here are the necessar files.
- settings.py
INSTALLED_APPS = [
'daphne',
other apps
]
Specify the ASGI application
ASGI_APPLICATION = 'root.asgi.application'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
AUTH_USER_MODEL = 'user.CustomUser'
ALLOWED_HOSTS = ['*']
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels.layers.InMemoryChannelLayer",
"ROUTING": "root.routing.application",
},
}
DATABASES = { 'default': { 'ENGINE' : 'django.db.backends.postgresql_psycopg2', 'NAME': 'postgres', 'HOST' :HOST, 'PASSWORD':PASSWORD, 'PORT': 5432, 'USER': 'postgres', } } MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', other middlewares ] attached are my asgi.py file, build and deployment logs. build seems to pass but deployment fails
DATABASES = { 'default': { 'ENGINE' : 'django.db.backends.postgresql_psycopg2', 'NAME': 'postgres', 'HOST' :HOST, 'PASSWORD':PASSWORD, 'PORT': 5432, 'USER': 'postgres', } } MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', other middlewares ] attached are my asgi.py file, build and deployment logs. build seems to pass but deployment fails
29 Replies
Project ID:
8d4a1ff4-5628-4e20-b965-b7f023aa198d
8d4a1ff4-5628-4e20-b965-b7f023aa198d
do you have
gunicorn
in your requirements.txt file?yes, i have. have got both gunicorn, daphne and uvicorn
build logs please https://bookmarklets.up.railway.app/log-downloader/
dont know if i did it well, but this is what i got-/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
/bin/bash: line 1: gunicorn: command not found
build logs please, then just send the file
I'm asking for the build logs
i really dont know what you mean by build logs and how i can get it, am still a novice here and i have spent days trying
send your Procfile
You've been sending your deploy logs (red), brody is asking for your build logs (blue)
Click on the build logs tab, then open the bookmarklet
mind to say my procfile has constantly changed from what you can see in the file to web:gunicorn root.asgi:application -k uvicorn.workers.UvicornWorker, to -web:gunicorn root.asgi:application. have kinda tried a lot just to know if it will work
thats my build log, now in my deployment log am getting daphne not found error, because i have changed both the start command and my procfile from gunicorn to daphne
well do you have
daphne
in your requirements.txt?
your start command is also slightly wrong, try this
daphne -b 0.0.0.0 -p $PORT chat.asgi:application
ok thanks, should i also change my procfile to-
daphne -b 0.0.0.0 -p $PORT chat.asgi:application
or leave it as-web: daphne -u /tmp/daphne.sock chat.asgi:application
worker: python manage.py runworker
1. yes change it to what I've said, that's why I've asked you to try the command I gave.
2. Railways support for Procfile's don't have worker support, for running workers you will need to add another service to your project on railway and set the start command accordingly.
i got this build error
i think i have got this sorted out, it was just a matter of space. its currently still deploying
its now in sort of an endless deployment loop, 10 mins and still counting, its still not deployed
build logs again then please
a bit strange now because am getting completed and not crashed but when i try to access the url of the site i get
Application failed to respond
please read the messages of the people who are trying to help you, it is not enjoyable for us to have to repeat ourselves
sorry, please i appreciate your time. You asked me to send the build logs, and i sent it including the deployment log incase you needed i too. please let me know. i guess i missed that daphne question. yes i have daphne in my requirements.txt. this is a part of my requirements.txt
coverage==4.4.1
cryptography==41.0.4
daphne==4.0.0
. in a brief nutshell, its a chatting website that makes use of django channels and tailwind for styling.I did some googling as it seems that Daphne isn't being installed correctly, this is what a comment on Stackoverflow says:
In general I suggest using uvicorn and gunicorn over daphne for ASGI applications. They are more lightweight and, in my opinion, more robust than django's default counter-part.https://stackoverflow.com/questions/77232409/asgidaphne-django-issue-in-production I'm not sure what the issue is with your code as Daphne should be installed during the build step, perhaps the linux equivalent to the PATH env variable isn't being updated? In any case, I suggest using gunicorn
no need to apologize, its all good, just please keep it in mind going forward ❤️
but i agree with adam, unless you have a very specific reason to be using daphne you should use gunicorn
sorry havent been online. please do you have a tutorial link i can follow for this?
thanks will look into it