R
Railway16mo ago
_kaiss

Django apps not responding anymore...

Hello all! I realized after the latest updates on railway (I don't know if it's related) but I noticed when I deploy my django apps, I see an error Application failed to respond but nothing on my logs. This is the third time I have this issue and when I deploy the same app in a regular VPS on Digitalocean it turns out fine. What's going on?
52 Replies
Percy
Percy16mo ago
Project ID: fa6ecf07-3925-4229-9a3a-2ba5b2bc79d4
_kaiss
_kaissOP16mo ago
fa6ecf07-3925-4229-9a3a-2ba5b2bc79d4 Hello?
fad
fad16mo ago
Could you perhaps post some logs from the build/deployment process? I know you said nothing on your logs, but I assume you were talking about the logs from the app.
_kaiss
_kaissOP16mo ago
I only see this: [2023-07-31 00:08:10 +0000] [1] [INFO] Starting gunicorn 21.2.0 [2023-07-31 00:08:10 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1) [2023-07-31 00:08:10 +0000] [1] [INFO] Using worker: sync [2023-07-31 00:08:10 +0000] [7] [INFO] Booting worker with pid: 7 [2023-07-31 00:08:10 +0000] [8] [INFO] Booting worker with pid: 8 [2023-07-31 00:08:10 +0000] [9] [INFO] Booting worker with pid: 9 [2023-07-31 00:08:10 +0000] [10] [INFO] Booting worker with pid: 10
MantisInABox
MantisInABox16mo ago
Can you show me your start command please?
_kaiss
_kaissOP16mo ago
Here is my entire Dockerfile: FROM python:3.10.8-slim-buster WORKDIR /usr/src/app ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 RUN pip install --upgrade pip COPY ./requirements.txt /usr/src/app RUN pip install -r requirements.txt COPY . /usr/src/app RUN python manage.py update_database_settings RUN python manage.py makemigrations RUN python manage.py migrate RUN DJANGO_SUPERUSER_USERNAME=kaiss \ DJANGO_SUPERUSER_PASSWORD=xxxxxxxx \ [email protected] \ python manage.py createsuperuser --noinput || true EXPOSE 8000 CMD ["gunicorn", "nafssi.wsgi:application", "-w", "4", "-b", "0.0.0.0:8000"]
MantisInABox
MantisInABox16mo ago
Since you are listening on port 8000, in your service on the railway dashboard, set an environment variable of PORT and set it to 8000 That should solve it for you
Brody
Brody16mo ago
FROM python:3.10.8-slim-buster

ARG PGHOST PGPORT PGUSER PGPASSWORD PGDATABASE DATABASE_URL

WORKDIR /usr/src/app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY requirements.txt ./
RUN pip install -r requirements.txt

COPY . ./

RUN python manage.py update_database_settings
RUN python manage.py makemigrations
RUN python manage.py migrate

CMD ["gunicorn", "nafssi.wsgi:application", "-w", "4"]
FROM python:3.10.8-slim-buster

ARG PGHOST PGPORT PGUSER PGPASSWORD PGDATABASE DATABASE_URL

WORKDIR /usr/src/app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY requirements.txt ./
RUN pip install -r requirements.txt

COPY . ./

RUN python manage.py update_database_settings
RUN python manage.py makemigrations
RUN python manage.py migrate

CMD ["gunicorn", "nafssi.wsgi:application", "-w", "4"]
MantisInABox
MantisInABox16mo ago
Because the railway container injects a port variable for you that’s random, it won’t always line up with what you expose from your app
Brody
Brody16mo ago
use this please what database type are you using? postgres?
_kaiss
_kaissOP16mo ago
yes
Brody
Brody16mo ago
one sec okay you are set, please use that dockerfile
MantisInABox
MantisInABox16mo ago
If you use Brody’s dockerfile, don’t set the environment variable in your service
Brody
Brody16mo ago
always use my dockerfiles 🙂
MantisInABox
MantisInABox16mo ago
Hush! 🤣🤣
_kaiss
_kaissOP16mo ago
hooold on now hahaha; I set the PORT var, I'll try if it works, if it doesn't I'll use Brody's one 😄
Brody
Brody16mo ago
please use mine anyway
_kaiss
_kaissOP16mo ago
hahah, ok now I have ERR_TOO_MANY_REDIRECTS
_kaiss
_kaissOP16mo ago
I have the exact same Dockerfile deployed on DO and with no problems
Brody
Brody16mo ago
please use my dockerfile, you should not be running createsuperuser from the dockerfile
MantisInABox
MantisInABox16mo ago
Yeah, this is a bad idea
_kaiss
_kaissOP16mo ago
I was just about to ask why did you remove the createsuperuser, I just did it because I created a new DB on railway and I wanted to directly start using the app for testing purposes only
MantisInABox
MantisInABox16mo ago
Every time you deploy, it will run that code
_kaiss
_kaissOP16mo ago
yes but it will do it only if the user does not exist
MantisInABox
MantisInABox16mo ago
You would want to use the CLI, and link the service and run the command that way
_kaiss
_kaissOP16mo ago
but anyways, I removed it, now I'm waiting for the autodeployment
MantisInABox
MantisInABox16mo ago
And if it fails to create the user, the deploy will fail, normally
Brody
Brody16mo ago
are you using cloudflare
_kaiss
_kaissOP16mo ago
yes, and I have 2 environments on railway: production (nafssi.ma) and development (dev.nafssi.ma) I added the 2 CNAMEs with and without proxy, both of them don't work which is weird because I launched a little AI product called debuggr.net last year and it's on railway and built with django and it works just fine you can try it it's fun 😄 The difference between debuggr.net and nafssi.ma is that with debuggr, I use the CNAME to point to the generated railway.app link I have, but with nafssi.ma, I used the CNAME value that railway.app provided me when I added the custom domain.
_kaiss
_kaissOP16mo ago
MantisInABox
MantisInABox16mo ago
Are your SSL settings set to Full?
_kaiss
_kaissOP16mo ago
I just set them to Full now as per the railway doc but in the debuggr.net project it's set to flexible and it works ok I think I made some progress, I ditched the domain names railway provided me with and I replaced the records by the generated railway domains, set them to proxy, and set the SSL mode to full now it gives me a 500 Error so I'm getting close
MantisInABox
MantisInABox16mo ago
Are you using your dockerfile still or Brody’s?
_kaiss
_kaissOP16mo ago
no Bordy's
MantisInABox
MantisInABox16mo ago
Okay. Cool. Do you still have the PORT environment variable set?
_kaiss
_kaissOP16mo ago
the thing is, I have set DEBUG to True, I have Error 500, and nothing on the logs no I removed the PORT var
MantisInABox
MantisInABox16mo ago
Hmmm Shouldn’t be giving trouble at this point… are you able to share the repo? I could look at it in about an hour or so when I get back on my computer
_kaiss
_kaissOP16mo ago
give me ur email
MantisInABox
MantisInABox16mo ago
GitHub username is vfehring
_kaiss
_kaissOP16mo ago
done
MantisInABox
MantisInABox16mo ago
Cool. I’ll look at it in a bit, and see if we can resolve this for you
_kaiss
_kaissOP16mo ago
Thank you so much! I think if we find the solution, it's gonna be the same for the other projects I have the same issue with (2 other django apps with the exact same issue...) are you guys django developers as well?
MantisInABox
MantisInABox16mo ago
I am Well, Django and flask
_kaiss
_kaissOP16mo ago
Great, I'm a Fractional CTO and I am a Django, Flask and FastAPI dev 😄 It's nice to meet you!
MantisInABox
MantisInABox16mo ago
Nice! I love Python. I do a lot more than just Python, but it’s one of my favorites
_kaiss
_kaissOP16mo ago
Me too! I went from Java to Python in 2014 Never went back 😄 Where are you from Vin?
MantisInABox
MantisInABox16mo ago
Houston
_kaiss
_kaissOP16mo ago
Great I'm from Morocco Casablanca to be exact
MantisInABox
MantisInABox16mo ago
Very nice. I have a friend over there
_kaiss
_kaissOP16mo ago
Very good! And I have a friend in Houston too 😄 an old college roomate who works in AWS now any luck?
MantisInABox
MantisInABox16mo ago
Haven’t had a chance to look at it. Moved my computer and had a full system meltdown. Will be looking at it tonight for sure Looking into this now for you
Want results from more Discord servers?
Add your server