Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a config file and tell Gunicorn to use it?

my app was running great but then I changed some things and now it can sometimes 'think' for more then 30 seconds before getting back to me. The problem is that Gunicorn times-out after 30 seconds:

[2016-03-28 18:25:52 +0000] [3] [CRITICAL] WORKER TIMEOUT (pid:8)
2016-03-28T18:25:52.625220+00:00 app[web.1]:
[2016-03-28 18:25:52 +0000] [8] [INFO] Worker exiting (pid: 8)

Now, I did some research and I know that I need to create a config file for Gunicorn and put a command to override Gunicorn's timeout default, like this: TIMEOUT=120 But how do I do that? I mean, how do I tell Gunicorn to look in, for example, gunicorn_config.txt and respect the laws I create for it there?

like image 772
Kristifer Szabo Avatar asked Oct 18 '25 11:10

Kristifer Szabo


1 Answers

Config files can be written as an INI file or as a Python file. If you're using a Python file (which is what I'd recommend), put this inside it:

timeout = 120

Or, if you want to use an INI file:

[server:main]
timeout = 120

Then, when you run Gunicorn, add a -c option to tell Gunicorn where your config file is, like this:

gunicorn -c config.py ...

See this file for a list of options that you can use in your config file.


For your example, you don't need a config file at all. Simply run Gunicorn with the --timeout option:

gunicorn --timeout 120 ...
like image 144
Aaron Christiansen Avatar answered Oct 21 '25 12:10

Aaron Christiansen