api: remove dependency on graceful

This library has no longer been needed since Go 1.8.
master
Jimmy Zelinskie 6 years ago
parent 2bbbad393b
commit 30644fcc01

@ -15,15 +15,14 @@
package api package api
import ( import (
"context"
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"io/ioutil" "io/ioutil"
"net"
"net/http" "net/http"
"time" "time"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/tylerb/graceful"
"github.com/coreos/clair/api/v3" "github.com/coreos/clair/api/v3"
"github.com/coreos/clair/database" "github.com/coreos/clair/database"
@ -61,42 +60,22 @@ func RunHealth(cfg *Config, store database.Datastore, st *stopper.Stopper) {
} }
log.WithField("addr", cfg.HealthAddr).Info("starting health API") log.WithField("addr", cfg.HealthAddr).Info("starting health API")
srv := &graceful.Server{ srv := http.Server{
Timeout: 10 * time.Second, // Interrupt health checks when stopping Addr: cfg.HealthAddr,
NoSignalHandling: true, // We want to use our own Stopper Handler: http.TimeoutHandler(newHealthHandler(store), cfg.Timeout, timeoutResponse),
Server: &http.Server{
Addr: cfg.HealthAddr,
Handler: http.TimeoutHandler(newHealthHandler(store), cfg.Timeout, timeoutResponse),
},
} }
listenAndServeWithStopper(srv, st, "", "")
log.Info("health API stopped")
}
// listenAndServeWithStopper wraps graceful.Server's
// ListenAndServe/ListenAndServeTLS and adds the ability to interrupt them with
// the provided stopper.Stopper.
func listenAndServeWithStopper(srv *graceful.Server, st *stopper.Stopper, certFile, keyFile string) {
go func() { go func() {
<-st.Chan() <-st.Chan()
srv.Stop(0) srv.Shutdown(context.TODO())
}() }()
var err error err := srv.ListenAndServe()
if certFile != "" && keyFile != "" { if err != nil && err != http.ErrServerClosed {
log.Info("API: TLS Enabled") log.Fatal(err)
err = srv.ListenAndServeTLS(certFile, keyFile)
} else {
err = srv.ListenAndServe()
} }
if err != nil { log.Info("health API stopped")
if opErr, ok := err.(*net.OpError); !ok || (ok && opErr.Op != "accept") {
log.Fatal(err)
}
}
} }
// tlsClientConfig initializes a *tls.Config using the given CA. The resulting // tlsClientConfig initializes a *tls.Config using the given CA. The resulting

@ -1,132 +1,77 @@
[ [
{ {
"project": "github.com/beorn7/perks/quantile", "project": "github.com/coreos/clair",
"licenses": [ "license": "Apache License 2.0",
{ "confidence": 1
"type": "MIT License",
"confidence": 0.9891304347826086
}
]
}, },
{ {
"project": "github.com/coreos/clair", "project": "github.com/beorn7/perks/quantile",
"licenses": [ "license": "MIT License",
{ "confidence": 0.989
"type": "Apache License 2.0",
"confidence": 1
}
]
}, },
{ {
"project": "github.com/coreos/pkg/timeutil", "project": "github.com/coreos/pkg/timeutil",
"licenses": [ "license": "Apache License 2.0",
{ "confidence": 1
"type": "Apache License 2.0",
"confidence": 1
}
]
}, },
{ {
"project": "github.com/golang/protobuf/proto", "project": "github.com/golang/protobuf/proto",
"licenses": [ "license": "BSD 3-clause \"New\" or \"Revised\" License",
{ "confidence": 0.92
"type": "BSD 3-clause \"New\" or \"Revised\" License", },
"confidence": 0.92 {
} "project": "github.com/google/uuid",
] "license": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.966
}, },
{ {
"project": "github.com/matttproud/golang_protobuf_extensions/pbutil", "project": "github.com/matttproud/golang_protobuf_extensions/pbutil",
"licenses": [ "license": "Apache License 2.0",
{ "confidence": 1
"type": "Apache License 2.0",
"confidence": 1
}
]
}, },
{ {
"project": "github.com/pborman/uuid", "project": "github.com/pborman/uuid",
"licenses": [ "license": "BSD 3-clause \"New\" or \"Revised\" License",
{ "confidence": 0.966
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.9663865546218487
}
]
}, },
{ {
"project": "github.com/prometheus/client_golang/prometheus", "project": "github.com/prometheus/client_golang/prometheus",
"licenses": [ "license": "Apache License 2.0",
{ "confidence": 1
"type": "Apache License 2.0",
"confidence": 1
}
]
}, },
{ {
"project": "github.com/prometheus/client_model/go", "project": "github.com/prometheus/client_model/go",
"licenses": [ "license": "Apache License 2.0",
{ "confidence": 1
"type": "Apache License 2.0",
"confidence": 1
}
]
}, },
{ {
"project": "github.com/prometheus/common", "project": "github.com/prometheus/common",
"licenses": [ "license": "Apache License 2.0",
{ "confidence": 1
"type": "Apache License 2.0",
"confidence": 1
}
]
}, },
{ {
"project": "github.com/prometheus/procfs", "project": "github.com/prometheus/procfs/xfs",
"licenses": [ "license": "Apache License 2.0",
{ "confidence": 1
"type": "Apache License 2.0",
"confidence": 1
}
]
}, },
{ {
"project": "github.com/sirupsen/logrus", "project": "github.com/sirupsen/logrus",
"licenses": [ "license": "MIT License",
{ "confidence": 1
"type": "MIT License",
"confidence": 1
}
]
}, },
{ {
"project": "github.com/stretchr/testify/assert", "project": "github.com/stretchr/testify/assert",
"licenses": [ "license": "MIT License",
{ "confidence": 0.943
"type": "MIT License",
"confidence": 0.9430051813471503
},
{
"type": "MIT License",
"confidence": 0.9430051813471503
}
]
}, },
{ {
"project": "github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew", "project": "github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew",
"licenses": [ "license": "ISC License",
{ "confidence": 0.985
"type": "ISC License",
"confidence": 0.9850746268656716
}
]
}, },
{ {
"project": "github.com/stretchr/testify/vendor/github.com/pmezard/go-difflib/difflib", "project": "github.com/stretchr/testify/vendor/github.com/pmezard/go-difflib/difflib",
"licenses": [ "license": "BSD 3-clause \"New\" or \"Revised\" License",
{ "confidence": 0.983
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.9830508474576272
}
]
} }
] ]

18
glide.lock generated

@ -1,5 +1,5 @@
hash: b5b9ebebad30becd361736196a015af23b1d9a616a375c7fc13823121fd17226 hash: 9bf7ad53b92119a17068b8724d9b406a7ca84b5bfcd0baba44b08c696a538b14
updated: 2017-06-05T16:11:29.019891941-04:00 updated: 2018-09-06T15:58:19.234504-04:00
imports: imports:
- name: github.com/beorn7/perks - name: github.com/beorn7/perks
version: 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9 version: 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
@ -23,9 +23,13 @@ imports:
- jsonpb - jsonpb
- proto - proto
- protoc-gen-go/descriptor - protoc-gen-go/descriptor
- ptypes
- ptypes/any - ptypes/any
- ptypes/empty - ptypes/duration
- ptypes/struct - ptypes/struct
- ptypes/timestamp
- name: github.com/google/uuid
version: e704694aed0ea004bb7eb1fc2e911d048a54606a
- name: github.com/grpc-ecosystem/go-grpc-prometheus - name: github.com/grpc-ecosystem/go-grpc-prometheus
version: 2500245aa6110c562d17020fb31a2c133d737799 version: 2500245aa6110c562d17020fb31a2c133d737799
- name: github.com/grpc-ecosystem/grpc-gateway - name: github.com/grpc-ecosystem/grpc-gateway
@ -35,7 +39,7 @@ imports:
- runtime/internal - runtime/internal
- utilities - utilities
- name: github.com/guregu/null - name: github.com/guregu/null
version: 41961cea0328defc5f95c1c473f89ebf0d1813f6 version: 80515d440932108546bcade467bb7d6968e812e2
subpackages: subpackages:
- zero - zero
- name: github.com/hashicorp/golang-lru - name: github.com/hashicorp/golang-lru
@ -53,7 +57,7 @@ imports:
subpackages: subpackages:
- pbutil - pbutil
- name: github.com/pborman/uuid - name: github.com/pborman/uuid
version: a97ce2ca70fa5a848076093f05e639a89ca34d06 version: adf5a7427709b9deb95d29d3fa8a2bf9cfd388f1
- name: github.com/pmezard/go-difflib - name: github.com/pmezard/go-difflib
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
subpackages: subpackages:
@ -81,11 +85,9 @@ imports:
- name: github.com/sirupsen/logrus - name: github.com/sirupsen/logrus
version: ba1b36c82c5e05c4f912a88eab0dcd91a171688f version: ba1b36c82c5e05c4f912a88eab0dcd91a171688f
- name: github.com/stretchr/testify - name: github.com/stretchr/testify
version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0 version: f35b8ab0b5a2cef36673838d662e249dd9c94686
subpackages: subpackages:
- assert - assert
- name: github.com/tylerb/graceful
version: 4654dfbb6ad53cb5e27f37d99b02e16c1872fbbb
- name: golang.org/x/net - name: golang.org/x/net
version: 59a0b19b5533c7977ddeb86b017bf507ed407b12 version: 59a0b19b5533c7977ddeb86b017bf507ed407b12
subpackages: subpackages:

@ -26,7 +26,5 @@ import:
version: ^1.1.4 version: ^1.1.4
subpackages: subpackages:
- assert - assert
- package: github.com/tylerb/graceful
version: ^1.2.15
- package: gopkg.in/yaml.v2 - package: gopkg.in/yaml.v2
- package: github.com/cockroachdb/cmux - package: github.com/cockroachdb/cmux

Loading…
Cancel
Save