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
No description
No description
No description
29 Replies
Percy
Percy12mo ago
Project ID: 8d4a1ff4-5628-4e20-b965-b7f023aa198d
nuelpeters47
nuelpeters4712mo ago
8d4a1ff4-5628-4e20-b965-b7f023aa198d
Brody
Brody12mo ago
do you have gunicorn in your requirements.txt file?
nuelpeters47
nuelpeters4712mo ago
yes, i have. have got both gunicorn, daphne and uvicorn
nuelpeters47
nuelpeters4712mo ago
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
Brody
Brody12mo ago
build logs please, then just send the file
Brody
Brody12mo ago
I'm asking for the build logs
nuelpeters47
nuelpeters4711mo ago
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
Brody
Brody11mo ago
send your Procfile
Adam
Adam11mo ago
You've been sending your deploy logs (red), brody is asking for your build logs (blue)
Adam
Adam11mo ago
No description
Adam
Adam11mo ago
Click on the build logs tab, then open the bookmarklet
nuelpeters47
nuelpeters4711mo ago
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
nuelpeters47
nuelpeters4711mo ago
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
Brody
Brody11mo ago
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
nuelpeters47
nuelpeters4711mo ago
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
Brody
Brody11mo ago
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.
nuelpeters47
nuelpeters4711mo ago
i got this build error
nuelpeters47
nuelpeters4711mo ago
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
Brody
Brody11mo ago
build logs again then please
nuelpeters47
nuelpeters4711mo ago
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
Brody
Brody11mo ago
please read the messages of the people who are trying to help you, it is not enjoyable for us to have to repeat ourselves
nuelpeters47
nuelpeters4711mo ago
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.
Adam
Adam11mo ago
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
Brody
Brody11mo ago
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
nuelpeters47
nuelpeters4711mo ago
sorry havent been online. please do you have a tutorial link i can follow for this? thanks will look into it
Want results from more Discord servers?
Add your server