Documentation
¶
Overview ¶
endless provides a drop in replacement for the `net/http` stl functions `ListenAndServe` and `ListenAndServeTLS` to achieve zero downtime restarts and code upgrades.
The code is based on the excellent post [Graceful Restart in Golang](http://grisha.org/blog/2014/06/03/graceful-restart-in-golang/) by [Grisha Trubetskoy](https://github.com/grisha). I took his code as a start. So a lot of credit to Grisha!
The original endless has been modified to include ListenAndServeTLSWithSNI for name-resoved TLS. Also a number of defects have been fixed.
Index ¶
- Constants
- Variables
- func ListenAndServe(addr string, handler http.Handler) error
- func ListenAndServeTLS(addr string, certFile string, keyFile string, handler http.Handler) error
- func ListenAndServeTLSWithSNI(addr string, handler http.Handler, tlsConfigs []TLSConfig) (err error)
- func NewServer(addr string, handler http.Handler) (srv *endlessServer)
- type TLSConfig
Constants ¶
const ( PRE_SIGNAL = iota POST_SIGNAL STATE_INIT STATE_RUNNING STATE_SHUTTING_DOWN STATE_TERMINATE )
Variables ¶
Functions ¶
func ListenAndServe ¶
ListenAndServe listens on the TCP network address addr and then calls Serve with handler to handle requests on incoming connections. Handler is typically nil, in which case the DefaultServeMux is used.
func ListenAndServeTLS ¶
ListenAndServeTLS acts identically to ListenAndServe, except that it expects HTTPS connections. Additionally, files containing a certificate and matching private key for the server must be provided. If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate followed by the CA's certificate.
func ListenAndServeTLSWithSNI ¶
func ListenAndServeTLSWithSNI(addr string, handler http.Handler, tlsConfigs []TLSConfig) (err error)
PJS func (srv *endlessServer) ListenAndServeTLSWithSNI(tlsConfigs []TLSConfig) (err error) { func ListenAndServeTLSWithSNI(srv *http.Server, tlsConfigs []TLSConfig) (err error) {
Types ¶
type TLSConfig ¶
type TLSConfig struct {
Certificate string // file name of Cert Key
Key string // file name of Cert Key
ProtocolMinVersion uint16 // ?? - defaults? I think to 1.2 the highest level - so why set
ProtocolMaxVersion uint16 // ?? - defaults?
Ciphers []uint16 // Flags of Ciphers - need special processing to read in
PreferServerCipherSuites bool // Flags of Ciphers - need special processing to read in
}