Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gunicorn receiving HUP signal and restarting #1824

Closed
talhachattha opened this issue Jun 29, 2018 · 16 comments
Closed

Gunicorn receiving HUP signal and restarting #1824

talhachattha opened this issue Jun 29, 2018 · 16 comments

Comments

@talhachattha
Copy link

talhachattha commented Jun 29, 2018

I have been running a gunicorn server with 4 workers and 40 threads, I receive a request to start a job for which I use pebble and its ProcessPool for work to remain asynchronous.
After running for few hours gunicorn automatically receives HUP signal and restarts causing those processes to stop and thus job failure.
Following is the output of what I receive.

[2018-06-28 09:50:33 -0700] [8266] [INFO] Starting gunicorn 19.8.1
[2018-06-28 09:50:33 -0700] [8266] [INFO] Listening at: http://0.0.0.0:7788 (8266)
[2018-06-28 09:50:33 -0700] [8266] [INFO] Using worker: threads
[2018-06-28 09:50:33 -0700] [8269] [INFO] Booting worker with pid: 8269
[2018-06-28 09:50:33 -0700] [8270] [INFO] Booting worker with pid: 8270
[2018-06-28 09:50:33 -0700] [8271] [INFO] Booting worker with pid: 8271
100%|██████████| 70/70 [03:55<00:00, 3.36s/it]
Run Completed, Saving the result
39%|███▉ | 4042/10240 [15:27<20:52, 4.95it/s]
[2018-06-28 10:27:47 -0700] [8266] [INFO] Handling signal: hup
[2018-06-28 10:27:47 -0700] [8266] [INFO] Hang up: Master
[2018-06-28 10:27:47 -0700] [22456] [INFO] Booting worker with pid: 22456
[2018-06-28 10:27:47 -0700] [22457] [INFO] Booting worker with pid: 22457
[2018-06-28 10:27:47 -0700] [22458] [INFO] Booting worker with pid: 22458

@tilgovi
Copy link
Collaborator

tilgovi commented Jun 29, 2018

Reloading is the expected response to HUP. The reload should be graceful. If it's not graceful, that is a bug with the threaded worker (related: #1236). If you don't want gunicorn to reload, do not send HUP.

@talhachattha
Copy link
Author

I am not sending HUP, OS sends it or somehow it automatically receives it.

@tilgovi
Copy link
Collaborator

tilgovi commented Jun 29, 2018

You will have to look into the process pool to figure out why Gunicorn receives HUP. Maybe your application receives HUP and the process pool sends it to all children, or maybe the process pool sends HUP for some other reason.

Is it causing errors, though? Do clients get disconnected in the middle of requests, or is it at least a graceful reload? If it is not graceful, there may a be a bug.

@talhachattha
Copy link
Author

I am unable to identify the source of HUP signal. But somehow gunicorn receives it from somewhere and gets restarted. I am unable to find a way for graceful closure. It just kills anything that is running and simply restarts.

@tilgovi
Copy link
Collaborator

tilgovi commented Jul 2, 2018

When you say "kills anything that is running" do you mean requests / connections or some background thread you have started? Are they long requests (websocket, long poll)? It should close connections gracefully, but there is a timeout after which it kills them hard.

@benoitc
Copy link
Owner

benoitc commented Jul 4, 2018

what are these hidden line though? Seems like the master is receiving an HUP signal right after ....

@talhachattha
Copy link
Author

@benoitc what hidden lines are you talking about?

@talhachattha
Copy link
Author

@tilgovi It simply restarts everything, I do run some background processes well. They also get killed and server as a whole restarts.

@benoitc
Copy link
Owner

benoitc commented Jul 4, 2018

@talhachattha

screen shot 2018-07-04 at 09 44 50

what is this ^^ ?

@talhachattha
Copy link
Author

@benoitc This is the progress of a job that I run in background in form of different processes.

@benoitc
Copy link
Owner

benoitc commented Jul 4, 2018

could that job be responsible of the HUP signal? What if you don't run it?

@talhachattha
Copy link
Author

The job is my product.
System is nothing without it.
I have to run it without getting this HUP signal

@benoitc
Copy link
Owner

benoitc commented Jul 4, 2018

well , something in your system is sending that HUP signal. You have to check if it’s not this job.

maybe you can also check the debug log or spew lov to see at which point it os happening

@talhachattha
Copy link
Author

What is spew lov?

@benoitc
Copy link
Owner

benoitc commented Jul 4, 2018

@talhachattha pups, it's the --spew function to trace all calls:

http://docs.gunicorn.org/en/stable/settings.html#spew

@benoitc
Copy link
Owner

benoitc commented Aug 27, 2018

closing issue, no more news since.

@benoitc benoitc closed this as completed Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants