container event container died when trying to deploy with dockerfile
I needed to use a dockerfile to install some important dependencies but now the deployment is failing on me with "container event container died" message in the deploy logs.
this is my dockerfile.
attached are the logs.
Solution:Jump to solution
After testing the response is successful however it takes 33 seconds and it seems like the pdf styling wasnt loading
fixed it by increasing gunicorn workers to 8 and running collectstatic...
36 Replies
Project ID:
643c9962-5fa0-449c-82e0-67b30f66c552
643c9962-5fa0-449c-82e0-67b30f66c552
ok it seems like i never run the application so i changed the docker file to this
but i got errors in collectstatic and migrate commands
i think the env vars arent present when building
tried this but getting container died again
can i get some help please
build and deploy logs please - https://bookmarklets.up.railway.app/log-downloader/
thank but i was able to finally deploy successfully when i removed a custom start command i put in previously
glad to hear that!
i have another question though,
i am trying to generate a pdf in django and then send it to frontend. everyhting works fine in development but in prod i get these errors
what do you get when you simply open the backend's domain in your browser?
does this have to do with railway limitations or something with the prod setup
i will try that
I'm confident enough to say that this would be a misconfiguration, I'm sure we can get to the cause
oh i remembered the request should be post with auth headers, so that wont be possible
GET /api/reports/session/59/
HTTP 401 Unauthorized
Allow: POST, OPTIONS
Content-Type: application/json
Vary: Accept
WWW-Authenticate: Bearer realm="api"
{
"type": "client_error",
"errors": [
{
"code": "not_authenticated",
"detail": "Authentication credentials were not provided.",
"attr": null
}
]
}
should i try to bypass that for testing?
is that what you get when you open the site in your browser?
yes
okay that's a good sign, as long as it's not a railway error page that's all that matters
looks like you will need to use some cors middleware
i do already and the rest of my app works fine, only this mew route that returns a pdf isnt working
maybe it's not really a cors error and instead it's returning something like a 500 status code that doesn't have cors headers on it, you'd want to test with something like postman that doesn't care about cors to see what's actually happening
Tried that and got the railway failed to respond error, 503 service unavailable
ah yes just as I suspected, your app did not respond
you will have to look to your deployment logs for errors on why it didn't respond
[2024-07-29 11:24:46 +0000] [79] [CRITICAL] WORKER TIMEOUT (pid:262)
[2024-07-29 11:24:46 +0000] [262] [INFO] Worker exiting (pid: 262)
[2024-07-29 11:24:47 +0000] [79] [ERROR] Worker (pid:262) exited with code 1
[2024-07-29 11:24:47 +0000] [79] [ERROR] Worker (pid:262) exited with code 1.
[2024-07-29 11:24:47 +0000] [343] [INFO] Booting worker with pid: 343
[2024-07-29 11:30:12 +0000] [79] [CRITICAL] WORKER TIMEOUT (pid:343)
[2024-07-29 11:30:13 +0000] [343] [INFO] Worker exiting (pid: 343)
[2024-07-29 11:30:13 +0000] [79] [ERROR] Worker (pid:343) exited with code 1
[2024-07-29 11:30:13 +0000] [79] [ERROR] Worker (pid:343) exited with code 1.
[2024-07-29 11:30:13 +0000] [424] [INFO] Booting worker with pid: 424
[2024-07-29 12:09:59 +0000] [79] [CRITICAL] WORKER TIMEOUT (pid:424)
[2024-07-29 12:09:59 +0000] [424] [INFO] Worker exiting (pid: 424)
[2024-07-29 12:10:00 +0000] [79] [ERROR] Worker (pid:424) exited with code 1
[2024-07-29 12:10:00 +0000] [79] [ERROR] Worker (pid:424) exited with code 1.
[2024-07-29 12:10:00 +0000] [533] [INFO] Booting worker with pid: 533
worker timed out? is that the issue?
that means a particular request took over the default of 30 seconds and was stopped, I assume generating a pdf should never take anywhere near 30 seconds?
anyway to increase default value?
you only need to if pdf generation is supposed to take longer than 30 seconds
I do alot of querysets to fetch the data for the pdf, so maybe its normal for it to take over 30 seconds, i am not sure so i want to test if increasing the value will fix the error, if it does then ill work on optimizing the process
fair enough, what's your current start command
i use a dockerfile
what is the start command in that bash file
its defined above it
gunicorn ${PROJ_NAME}.wsgi:application --bind "0.0.0.0:$RUN_PORT"
i define the script in the same place, there is no external bash file
what do i do with it?
you would want to set this flag - https://docs.gunicorn.org/en/stable/settings.html#timeout
to something greater than 30
Solution
After testing the response is successful however it takes 33 seconds and it seems like the pdf styling wasnt loading
fixed it by increasing gunicorn workers to 8 and running collectstatic
any downside to settings workers to 8? do i still need to optimise my querying?
how long does the request to generate a pdf take now?
a second or so
okay then id say thats pretty good
Great. You've been incredibly helpful! Thank you sincerely.
no problem!