fabiolb / fabio

Consul Load-Balancing made simple
https://fabiolb.net
MIT License
7.25k stars 619 forks source link

SIGTERM + Gracefully closing connections #782

Closed tecnobrat closed 4 years ago

tecnobrat commented 4 years ago

My initial tests indicate that fabio shuts down immediately when it gets a SIGTERM and doesn't let HTTP requests finish. Infact it returns 502 for any requests that are currently inflight.

I added an upstream that always takes 10 seconds to respond.

I started an HTTP request, and then I stopped the docker container:

2020/08/14 18:33:43 [INFO] Caught SIGTERM. Exiting

The HTTP request that had been running for 2-3 seconds at the time, errored immediately after printing the SIGTERM log line with:

* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 502
< content-length: 0
< date: Fri, 14 Aug 2020 18:33:43 GMT

Seems like fabio should wait until all connections are completed before shutting down, to prevent 502s. I would expect a timeout of some sort where it waits and then terminates those connections if they are still not complete.

nathanejohnson commented 4 years ago

@tecnobrat have you configured proxy.shutdownwnwait?

tecnobrat commented 4 years ago

Oh my goodness, I have not. Didn't see that option!

tecnobrat commented 4 years ago

I have confirmed that makes it work, thank you @nathanejohnson