R
Railway•13mo 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•13mo ago
Project ID: 3aab35c7-7d7e-441a-b845-39e22b14d35d
Brody
Brody•13mo ago
those are the build logs
Yuji
YujiOP•13mo ago
It is not building only. after migration
Brody
Brody•13mo ago
deploy logs please
Brody
Brody•13mo ago
this is an issue with your code
Yuji
YujiOP•13mo ago
ok
Yuji
YujiOP•13mo ago
After fixing the code issue I am getting this error
Brody
Brody•13mo ago
can you connect to the database on railway locally?
Yuji
YujiOP•13mo ago
yes
Brody
Brody•13mo ago
in the dockerfile, can you try adding a 3 second sleep before starting your app
Yuji
YujiOP•13mo ago
okay even after adding sleep for 3 seconds it is giving me the same error
Brody
Brody•13mo ago
show me the how you've added the sleep?
Yuji
YujiOP•13mo 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•13mo ago
that's just a sleep during build, add the sleep to the cmd
Yuji
YujiOP•13mo ago
Sorry, I am not understanding. Can you give me an example
Brody
Brody•13mo 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
YujiOP•13mo ago
getting the same error...😔
Brody
Brody•13mo ago
show me how you are connecting to the database in code
Yuji
YujiOP•13mo ago
No description
Brody
Brody•13mo ago
do you have all those variables in your service variables?
Yuji
YujiOP•13mo ago
yes
No description
Brody
Brody•13mo ago
do they show properly when you click the eye icon?
Yuji
YujiOP•13mo ago
yes, they are showing
Brody
Brody•13mo 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
YujiOP•13mo ago
But it is working locally
No description
Brody
Brody•13mo 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
YujiOP•13mo ago
It solved
Brody
Brody•13mo ago
awesome, what was the solution
Yuji
YujiOP•13mo ago
don't know It automatically solved... 😅
Brody
Brody•13mo ago
oh that's not ideal
Yuji
YujiOP•13mo ago
I just redeploy
Brody
Brody•13mo ago
interesting
Want results from more Discord servers?
Add your server