caddyhttp: Honor grace period in background (#5043)

* caddyhttp: Honor grace period in background

This avoids blocking during config reloads.

* Don't quit process until servers shut down

* Make tests more likely to pass on fast CI (#5045)

* caddyhttp: Even faster shutdowns

Simultaneously shut down all HTTP servers, rather than one at a time.

In practice there usually won't be more than 1 that lingers. But this
code ensures that they all Shutdown() in their own goroutine
and then we wait for them at the end (if exiting).

We also wait for them to start up so we can be fairly confident the
shutdowns have begun; i.e. old servers no longer
accepting new connections.

* Fix comment typo

* Pull functions out of loop, for readability
This commit is contained in:
Matt Holt
2022-09-19 21:54:47 -06:00
committed by GitHub
parent 0950ba4f0b
commit da8b7fe58f
9 changed files with 78 additions and 10 deletions

View File

@ -18,6 +18,7 @@ func TestSRVReverseProxy(t *testing.T) {
{
"apps": {
"http": {
"grace_period": 1,
"servers": {
"srv0": {
"listen": [
@ -50,6 +51,7 @@ func TestSRVWithDial(t *testing.T) {
{
"apps": {
"http": {
"grace_period": 1,
"servers": {
"srv0": {
"listen": [
@ -115,6 +117,7 @@ func TestDialWithPlaceholderUnix(t *testing.T) {
{
"apps": {
"http": {
"grace_period": 1,
"servers": {
"srv0": {
"listen": [
@ -156,6 +159,7 @@ func TestReverseProxyWithPlaceholderDialAddress(t *testing.T) {
{
"apps": {
"http": {
"grace_period": 1,
"servers": {
"srv0": {
"listen": [
@ -239,6 +243,7 @@ func TestReverseProxyWithPlaceholderTCPDialAddress(t *testing.T) {
{
"apps": {
"http": {
"grace_period": 1,
"servers": {
"srv0": {
"listen": [
@ -321,6 +326,7 @@ func TestSRVWithActiveHealthcheck(t *testing.T) {
{
"apps": {
"http": {
"grace_period": 1,
"servers": {
"srv0": {
"listen": [