Documentation ¶
Overview ¶
Package lifecycle provides variables for controlling an application's lifecycle, and a function for gracefully shutting down an http.Server.
It exposes these variables with two HTTP handlers:
/live /ready
The package is sometimes only imported for the side effect of registering its HTTP handlers. To use it this way, link this package into your program:
import _ "github.com/skuid/spec/lifecycle"
When not using the default multiplexer in the http.ListenAndServe function call, the handlers are available for adding separately.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Ready = true
Ready is a boolean that represents whether the application is ready.
var Shutdown = false
Shutdown is a boolean that represents whether the application has received a SIGTERM.
var ShutdownTimer int64 = 15
ShutdownTimer is a configuration option for this package that sets the amount of time in seconds an application should wait before exiting after receiving a SIGTERM.
Functions ¶
func LivenessHandler ¶
func LivenessHandler(w http.ResponseWriter, r *http.Request)
LivenessHandler reports on the status of Shutdown
func ReadinessHandler ¶
func ReadinessHandler(w http.ResponseWriter, r *http.Request)
ReadinessHandler reports on the status of Ready
func ShutdownOnTerm ¶
ShutdownOnTerm accepts an *http.Server and will gracefully shut it down when a SIGTERM is received, after ShutdownTimer seconds (default 15)
Types ¶
This section is empty.