#Flask application contains deploy error WORKER TIMEOUT

42 messages · Page 1 of 1 (latest)

amber vector
#

My flask application for a chatbot builds successfully but there is an issue in the deploy logs where it downloads nltk resources needed adn then after a few seconds, this error occurs,
[2023-05-02 14:46:57 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:668)
[2023-05-02 14:46:57 +0000] [668] [INFO] Worker exiting (pid: 668)
[2023-05-02 14:46:58 +0000] [715] [INFO] Booting worker with pid: 715

terse haloBOT
#

Project ID: 9430bc25-9d4f-4be3-a344-a1d88b7677ab

amber vector
#

9430bc25-9d4f-4be3-a344-a1d88b7677ab

tidal vortex
#

gunicorn?

amber vector
#

yes

tidal vortex
#

gunicorn's default timeout is 30 seconds

#

should your endpoint be taking longer than 30 seconds?

amber vector
#

The chatbot files do take some time, so the server does take some time to start up when run locally, but all endpoints only take a few seconds

#

after the server starts up while testing locally

tidal vortex
#

how long does it take to start up?

amber vector
#

around 1 minute

tidal vortex
#

yep 60 > 30

amber vector
#

Thanks for the help :p, I am not familiar with flask applications, the code is being maintained by another person. I take care of deployments for this project we are developing. I don't think gunicorn is being used locally and the flask application is run on dev mode locally. Gunicorn is being used to serve the app in railway right? So my question is how do i change railway settings to increase timeout of gunicorn or is that provided in the link you shared right now.

tidal vortex
#

okay, do you have access to the codebase and can make changes to it?

amber vector
#

yes i do

tidal vortex
#

does it have a Procfile or railway.toml/json file?

amber vector
#

it has a procfile

tidal vortex
#

send the contents of the procfile

amber vector
#

web: gunicorn main:app

tidal vortex
#
web: gunicorn --timeout 120 main:app
#

there you go, use that for your Procfile

amber vector
#

ok let me try

amber vector
#

Hi Brody, the increasing timeout doesn't seem to work unfortunately. I contacted the person who does the code for the chatbot and he timed the server start up, and it takes around 43 secs, he said. Currently in the deploy logs in railway it initially dowloads some nltk resources and then nothing comes until the worker time out issue pops up again. I also checked the time in the logs and it does run for 2 minutes. Any help would be much appreciated

tidal vortex
#

if startup takes longer than 120 seconds, increase it

#

or ideally fix the inefficient code

amber vector
#

the code takes only 40s to loadup locally. Also the deploy logs are unchanged for more than a min after downloading the nltk resources until the 2min mark cross when the worker timeouts. A similar process takes place locally but there it loads up in 40s

tidal vortex
#

maybe move the downloads and such to a setup phase that runs during build

amber vector
#

ok I'll pass on the information, thanks for the support Brody

tidal vortex
#

no problem

#

also might just be easier for the code maintainer to be here too

amber vector
#

Yea i am in constant contact with him so any issues i can forward to him

#

Also right now we increased timeout to 5 minutes to just simply check, and some new logs were found in the deploy logs

#

This is the error. Now we are using pyenchant package we installed from pip in our codebase, so that could be added simply to requirements.txt to install it. But here it's talking about the enchant library which i presume is used by the python package. Any idea if this is the culprit for the worker timing out and how this library can be added

#

reading the docs, they say about the enchant c library being required to be downloaded for the python package pyenchant to work. So how to add this library to our project

tidal vortex
#

try this in a nixpacks.toml file

[phases.setup]
nixPkgs = ['...', 'enchant']
amber vector
#

ok will try

tidal vortex
#

did you try the nixpacks.toml file??

amber vector
#

the build is currently going on

amber vector
#

okay so this worked and there were issues with other packages too which we solved too and now the server is working perfectly. We also reduced the total time to 20 secs. So again thanks for all your help Brody, without you this wouldn't have been possible. You were a lifesaver :p