@@ -71,6 +71,7 @@ const (
7171 getCertPath = "/get/cert/"
7272 getCertInfoPath = "/get/certinfo/"
7373 buildIDPath = "/build"
74+ healthPath = "/health"
7475)
7576
7677const (
@@ -425,6 +426,7 @@ func (wfe *WebFrontEndImpl) Handler(stats prometheus.Registerer, oTelHTTPOptions
425426 wfe .HandleFunc (m , getCertPath , wfe .Certificate , "GET" )
426427 wfe .HandleFunc (m , getCertInfoPath , wfe .CertificateInfo , "GET" )
427428 wfe .HandleFunc (m , buildIDPath , wfe .BuildID , "GET" )
429+ wfe .HandleFunc (m , healthPath , wfe .HttpHealth , "GET" )
428430
429431 // Endpoint for draft-ietf-acme-ari
430432 if features .Get ().ServeRenewalInfo {
@@ -1801,6 +1803,23 @@ func (wfe *WebFrontEndImpl) BuildID(ctx context.Context, logEvent *web.RequestEv
18011803 }
18021804}
18031805
1806+ // HttpHealth tells the requester whether we're ready to serve requests.
1807+ func (wfe * WebFrontEndImpl ) HttpHealth (ctx context.Context , _ * web.RequestEvent , response http.ResponseWriter , _ * http.Request ) {
1808+ status := http .StatusOK
1809+ details := "OK"
1810+
1811+ if ! wfe .txnBuilder .Ready () {
1812+ status = http .StatusServiceUnavailable
1813+ details = "waiting for overrides"
1814+ }
1815+
1816+ response .Header ().Set ("Content-Type" , "text/plain" )
1817+ response .WriteHeader (status )
1818+ if _ , err := fmt .Println (response , details ); err != nil {
1819+ wfe .log .Warningf ("Could not write response: %s" , err )
1820+ }
1821+ }
1822+
18041823// Options responds to an HTTP OPTIONS request.
18051824func (wfe * WebFrontEndImpl ) Options (response http.ResponseWriter , request * http.Request , methodsStr string , methodsMap map [string ]bool ) {
18061825 // Every OPTIONS request gets an Allow header with a list of supported methods.
0 commit comments