R
Railway•7mo ago
Yuji

After migration database of redis my api is broken

The api is working on locally on my computer which is connected to railway redis database and it is working perfectly but on the railway it is not working. I have also changed the environment variable.
36 Replies
Percy
Percy•7mo ago
Project ID: 3aab35c7-7d7e-441a-b845-39e22b14d35d
Brody
Brody•7mo ago
those are the build logs
Yuji
Yuji•7mo ago
It is not building only. after migration
Brody
Brody•7mo ago
deploy logs please
Brody
Brody•7mo ago
this is an issue with your code
Yuji
Yuji•7mo ago
ok
Yuji
Yuji•7mo ago
After fixing the code issue I am getting this error
Brody
Brody•7mo ago
can you connect to the database on railway locally?
Yuji
Yuji•7mo ago
yes
Brody
Brody•7mo ago
in the dockerfile, can you try adding a 3 second sleep before starting your app
Yuji
Yuji•7mo ago
okay even after adding sleep for 3 seconds it is giving me the same error
Brody
Brody•7mo ago
show me the how you've added the sleep?
Yuji
Yuji•7mo ago
FROM python:3.11-alpine WORKDIR /app COPY requirements.txt ./ RUN pip install -r requirements.txt COPY . . EXPOSE 8000 RUN sleep 3 CMD ["gunicorn", "api:app"]
Brody
Brody•7mo ago
that's just a sleep during build, add the sleep to the cmd
Yuji
Yuji•7mo ago
Sorry, I am not understanding. Can you give me an example
Brody
Brody•7mo ago
FROM python:3.11-alpine

WORKDIR /app

COPY requirements.txt ./

RUN pip install -r requirements.txt

COPY . .

CMD sleep 3 && gunicorn api:app
FROM python:3.11-alpine

WORKDIR /app

COPY requirements.txt ./

RUN pip install -r requirements.txt

COPY . .

CMD sleep 3 && gunicorn api:app
Yuji
Yuji•7mo ago
getting the same error...😔
Brody
Brody•7mo ago
show me how you are connecting to the database in code
Yuji
Yuji•7mo ago
No description
Brody
Brody•7mo ago
do you have all those variables in your service variables?
Yuji
Yuji•7mo ago
yes
No description
Brody
Brody•7mo ago
do they show properly when you click the eye icon?
Yuji
Yuji•7mo ago
yes, they are showing
Brody
Brody•7mo ago
then this is also looking like a code issue, can you get your app to print an actually reason for the connection failure instead of a panic?
Yuji
Yuji•7mo ago
But it is working locally
No description
Brody
Brody•7mo ago
that does not mean its not a code issue, for example, you are running it in development mode in that screenshot, but in your dockerfile you run it with gunicorn, you absolutely do want to run it with gunicorn when on railway, but these types of things can cause discrepancies
Yuji
Yuji•7mo ago
It solved
Brody
Brody•7mo ago
awesome, what was the solution
Yuji
Yuji•7mo ago
don't know It automatically solved... 😅
Brody
Brody•7mo ago
oh that's not ideal
Yuji
Yuji•7mo ago
I just redeploy
Brody
Brody•7mo ago
interesting