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
#Flask application contains deploy error WORKER TIMEOUT
42 messages · Page 1 of 1 (latest)
Project ID: 9430bc25-9d4f-4be3-a344-a1d88b7677ab
9430bc25-9d4f-4be3-a344-a1d88b7677ab
gunicorn?
yes
gunicorn's default timeout is 30 seconds
should your endpoint be taking longer than 30 seconds?
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
how long does it take to start up?
around 1 minute
yep 60 > 30
change the timeout value, here's the docs for that
https://docs.gunicorn.org/en/latest/settings.html#timeout
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.
okay, do you have access to the codebase and can make changes to it?
yes i do
does it have a Procfile or railway.toml/json file?
it has a procfile
send the contents of the procfile
web: gunicorn main:app
ok let me try
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
if startup takes longer than 120 seconds, increase it
or ideally fix the inefficient code
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
maybe move the downloads and such to a setup phase that runs during build
ok I'll pass on the information, thanks for the support Brody
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
ImportError: The 'enchant' C library was not found and maybe needs to be installed.
See https://pyenchant.github.io/pyenchant/install.html
for details
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
try this in a nixpacks.toml file
[phases.setup]
nixPkgs = ['...', 'enchant']
ok will try
I found a similar issue here for another deployment service i assume , https://discuss.streamlit.io/t/importerror-the-enchant-c-library-was-not-found-and-maybe-needs-to-be-installed/32628. Can this soln be reproduced in railway?
did you try the nixpacks.toml file??
the build is currently going on
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