Issue #239 - Add a build ID method to WFE, and print Info on startup for all
This commit is contained in:
parent
d1321f2d78
commit
8766edaa93
7
Makefile
7
Makefile
|
@ -12,6 +12,9 @@ OBJECTS = activity-monitor \
|
||||||
boulder-wfe \
|
boulder-wfe \
|
||||||
ocsp-updater
|
ocsp-updater
|
||||||
|
|
||||||
|
REVID = $(shell git symbolic-ref --short HEAD):$(shell git rev-parse --short HEAD)
|
||||||
|
BUILD_ID_VAR = github.com/letsencrypt/boulder/core.BuildID
|
||||||
|
|
||||||
.PHONY: all build
|
.PHONY: all build
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
|
@ -23,8 +26,8 @@ pre:
|
||||||
|
|
||||||
# Compile each of the binaries
|
# Compile each of the binaries
|
||||||
$(OBJECTS): pre
|
$(OBJECTS): pre
|
||||||
go build -o ./bin/$@ cmd/$@/main.go
|
go build -o ./bin/$@ -ldflags "-X $(BUILD_ID_VAR) $(REVID)" cmd/$@/main.go
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJDIR)/*
|
rm -f $(OBJDIR)/*
|
||||||
rmdir $(OBJDIR)
|
rmdir $(OBJDIR)
|
||||||
|
|
|
@ -12,13 +12,14 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cactus/go-statsd-client/statsd"
|
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cactus/go-statsd-client/statsd"
|
||||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/streadway/amqp"
|
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/streadway/amqp"
|
||||||
|
|
||||||
"github.com/letsencrypt/boulder/analysis"
|
"github.com/letsencrypt/boulder/analysis"
|
||||||
"github.com/letsencrypt/boulder/cmd"
|
"github.com/letsencrypt/boulder/cmd"
|
||||||
blog "github.com/letsencrypt/boulder/log"
|
blog "github.com/letsencrypt/boulder/log"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -150,6 +151,8 @@ func main() {
|
||||||
|
|
||||||
go cmd.ProfileCmd("AM", stats)
|
go cmd.ProfileCmd("AM", stats)
|
||||||
|
|
||||||
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
startMonitor(ch, auditlogger, stats)
|
startMonitor(ch, auditlogger, stats)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,8 @@ func main() {
|
||||||
cas, err := rpc.NewCertificateAuthorityServer(c.AMQP.CA.Server, ch, cai)
|
cas, err := rpc.NewCertificateAuthorityServer(c.AMQP.CA.Server, ch, cai)
|
||||||
cmd.FailOnError(err, "Unable to create CA server")
|
cmd.FailOnError(err, "Unable to create CA server")
|
||||||
|
|
||||||
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
cmd.RunUntilSignaled(auditlogger, cas, closeChan)
|
cmd.RunUntilSignaled(auditlogger, cas, closeChan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,8 @@ func main() {
|
||||||
ras, err := rpc.NewRegistrationAuthorityServer(c.AMQP.RA.Server, ch, &rai)
|
ras, err := rpc.NewRegistrationAuthorityServer(c.AMQP.RA.Server, ch, &rai)
|
||||||
cmd.FailOnError(err, "Unable to create RA server")
|
cmd.FailOnError(err, "Unable to create RA server")
|
||||||
|
|
||||||
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
cmd.RunUntilSignaled(auditlogger, ras, closeChan)
|
cmd.RunUntilSignaled(auditlogger, ras, closeChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@ func main() {
|
||||||
|
|
||||||
sas := rpc.NewStorageAuthorityServer(c.AMQP.SA.Server, ch, sai)
|
sas := rpc.NewStorageAuthorityServer(c.AMQP.SA.Server, ch, sai)
|
||||||
|
|
||||||
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
cmd.RunUntilSignaled(auditlogger, sas, closeChan)
|
cmd.RunUntilSignaled(auditlogger, sas, closeChan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,8 @@ func main() {
|
||||||
vas, err := rpc.NewValidationAuthorityServer(c.AMQP.VA.Server, ch, &vai)
|
vas, err := rpc.NewValidationAuthorityServer(c.AMQP.VA.Server, ch, &vai)
|
||||||
cmd.FailOnError(err, "Unable to create VA server")
|
cmd.FailOnError(err, "Unable to create VA server")
|
||||||
|
|
||||||
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
cmd.RunUntilSignaled(auditlogger, vas, closeChan)
|
cmd.RunUntilSignaled(auditlogger, vas, closeChan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cactus/go-statsd-client/statsd"
|
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cactus/go-statsd-client/statsd"
|
||||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/streadway/amqp"
|
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/streadway/amqp"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/letsencrypt/boulder/cmd"
|
"github.com/letsencrypt/boulder/cmd"
|
||||||
blog "github.com/letsencrypt/boulder/log"
|
blog "github.com/letsencrypt/boulder/log"
|
||||||
|
@ -110,6 +110,8 @@ func main() {
|
||||||
wfe.BaseURL = c.WFE.BaseURL
|
wfe.BaseURL = c.WFE.BaseURL
|
||||||
wfe.HandlePaths()
|
wfe.HandlePaths()
|
||||||
|
|
||||||
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
// Add HandlerTimer to output resp time + success/failure stats to statsd
|
// Add HandlerTimer to output resp time + success/failure stats to statsd
|
||||||
err = http.ListenAndServe(c.WFE.ListenAddress, HandlerTimer(http.DefaultServeMux, stats))
|
err = http.ListenAndServe(c.WFE.ListenAddress, HandlerTimer(http.DefaultServeMux, stats))
|
||||||
cmd.FailOnError(err, "Error starting HTTP server")
|
cmd.FailOnError(err, "Error starting HTTP server")
|
||||||
|
|
|
@ -117,6 +117,8 @@ func main() {
|
||||||
wfei.BaseURL = c.WFE.BaseURL
|
wfei.BaseURL = c.WFE.BaseURL
|
||||||
wfei.HandlePaths()
|
wfei.HandlePaths()
|
||||||
|
|
||||||
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
fmt.Fprintf(os.Stderr, "Server running, listening on %s...\n", c.WFE.ListenAddress)
|
fmt.Fprintf(os.Stderr, "Server running, listening on %s...\n", c.WFE.ListenAddress)
|
||||||
err = http.ListenAndServe(c.WFE.ListenAddress, HandlerTimer(http.DefaultServeMux, stats))
|
err = http.ListenAndServe(c.WFE.ListenAddress, HandlerTimer(http.DefaultServeMux, stats))
|
||||||
cmd.FailOnError(err, "Error starting HTTP server")
|
cmd.FailOnError(err, "Error starting HTTP server")
|
||||||
|
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"golang.org/x/crypto/ocsp"
|
"golang.org/x/crypto/ocsp"
|
||||||
|
|
||||||
"github.com/letsencrypt/boulder/cmd"
|
"github.com/letsencrypt/boulder/cmd"
|
||||||
|
"github.com/letsencrypt/boulder/core"
|
||||||
blog "github.com/letsencrypt/boulder/log"
|
blog "github.com/letsencrypt/boulder/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -134,6 +135,8 @@ func main() {
|
||||||
// Configure HTTP
|
// Configure HTTP
|
||||||
http.Handle(c.OCSP.Path, cfocsp.Responder{Source: src})
|
http.Handle(c.OCSP.Path, cfocsp.Responder{Source: src})
|
||||||
|
|
||||||
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
// Add HandlerTimer to output resp time + success/failure stats to statsd
|
// Add HandlerTimer to output resp time + success/failure stats to statsd
|
||||||
err = http.ListenAndServe(c.WFE.ListenAddress, HandlerTimer(http.DefaultServeMux, stats))
|
err = http.ListenAndServe(c.WFE.ListenAddress, HandlerTimer(http.DefaultServeMux, stats))
|
||||||
cmd.FailOnError(err, "Error starting HTTP server")
|
cmd.FailOnError(err, "Error starting HTTP server")
|
||||||
|
|
|
@ -181,6 +181,8 @@ func main() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
auditlogger.Info(app.VersionString())
|
||||||
|
|
||||||
// Calculate the cut-off timestamp
|
// Calculate the cut-off timestamp
|
||||||
dur, err := time.ParseDuration(c.OCSP.MinTimeToExpiry)
|
dur, err := time.ParseDuration(c.OCSP.MinTimeToExpiry)
|
||||||
cmd.FailOnError(err, "Could not parse MinTimeToExpiry from config.")
|
cmd.FailOnError(err, "Could not parse MinTimeToExpiry from config.")
|
||||||
|
|
|
@ -38,6 +38,7 @@ import (
|
||||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/codegangsta/cli"
|
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/codegangsta/cli"
|
||||||
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/streadway/amqp"
|
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/streadway/amqp"
|
||||||
"github.com/letsencrypt/boulder/ca"
|
"github.com/letsencrypt/boulder/ca"
|
||||||
|
"github.com/letsencrypt/boulder/core"
|
||||||
blog "github.com/letsencrypt/boulder/log"
|
blog "github.com/letsencrypt/boulder/log"
|
||||||
"github.com/letsencrypt/boulder/rpc"
|
"github.com/letsencrypt/boulder/rpc"
|
||||||
)
|
)
|
||||||
|
@ -163,6 +164,11 @@ func (as *AppShell) Run() {
|
||||||
FailOnError(err, "Failed to run application")
|
FailOnError(err, "Failed to run application")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VersionString produces a friendly Application version string
|
||||||
|
func (as *AppShell) VersionString() string {
|
||||||
|
return fmt.Sprintf("%s (version %s, build %s)", as.App.Name, as.App.Version, core.GetBuildID())
|
||||||
|
}
|
||||||
|
|
||||||
// FailOnError exits and prints an error message if we encountered a problem
|
// FailOnError exits and prints an error message if we encountered a problem
|
||||||
func FailOnError(err error, msg string) {
|
func FailOnError(err error, msg string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
15
core/util.go
15
core/util.go
|
@ -28,6 +28,12 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Package Variables Variables
|
||||||
|
|
||||||
|
// BuildID is set by the compiler (using -ldflags "-X core.BuildID $(git rev-parse --short HEAD)")
|
||||||
|
// and is used by GetBuildID
|
||||||
|
var BuildID string
|
||||||
|
|
||||||
// Errors
|
// Errors
|
||||||
|
|
||||||
type NotSupportedError string
|
type NotSupportedError string
|
||||||
|
@ -232,3 +238,12 @@ func StringToSerial(serial string) (*big.Int, error) {
|
||||||
_, err := fmt.Sscanf(serial, "%032x", &serialNum)
|
_, err := fmt.Sscanf(serial, "%032x", &serialNum)
|
||||||
return &serialNum, err
|
return &serialNum, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBuildID identifies what build is running.
|
||||||
|
func GetBuildID() (retID string) {
|
||||||
|
retID = BuildID
|
||||||
|
if retID == "" {
|
||||||
|
retID = "Unspecified"
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -48,3 +48,7 @@ func TestSerialUtils(t *testing.T) {
|
||||||
test.AssertEquals(t, fmt.Sprintf("%v", err), "Serial number should be 32 characters long")
|
test.AssertEquals(t, fmt.Sprintf("%v", err), "Serial number should be 32 characters long")
|
||||||
fmt.Println(badSerial)
|
fmt.Println(badSerial)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBuildID(t *testing.T) {
|
||||||
|
test.AssertEquals(t, "Unspecified", GetBuildID())
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ const (
|
||||||
RevokeCertPath = "/acme/revoke-cert/"
|
RevokeCertPath = "/acme/revoke-cert/"
|
||||||
TermsPath = "/terms"
|
TermsPath = "/terms"
|
||||||
IssuerPath = "/acme/issuer-cert"
|
IssuerPath = "/acme/issuer-cert"
|
||||||
|
BuildIDPath = "/build"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WebFrontEndImpl represents a Boulder web service and its resources
|
// WebFrontEndImpl represents a Boulder web service and its resources
|
||||||
|
@ -88,6 +89,7 @@ func (wfe *WebFrontEndImpl) HandlePaths() {
|
||||||
http.HandleFunc(RevokeCertPath, wfe.RevokeCertificate)
|
http.HandleFunc(RevokeCertPath, wfe.RevokeCertificate)
|
||||||
http.HandleFunc(TermsPath, wfe.Terms)
|
http.HandleFunc(TermsPath, wfe.Terms)
|
||||||
http.HandleFunc(IssuerPath, wfe.Issuer)
|
http.HandleFunc(IssuerPath, wfe.Issuer)
|
||||||
|
http.HandleFunc(BuildIDPath, wfe.BuildID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method implementations
|
// Method implementations
|
||||||
|
@ -744,3 +746,12 @@ func (wfe *WebFrontEndImpl) Issuer(w http.ResponseWriter, r *http.Request) {
|
||||||
wfe.log.Warning(fmt.Sprintf("Could not write response: %s", err))
|
wfe.log.Warning(fmt.Sprintf("Could not write response: %s", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BuildID tells the requestor what build we're running.
|
||||||
|
func (wfe *WebFrontEndImpl) BuildID(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
if _, err := fmt.Fprintln(w, core.GetBuildID()); err != nil {
|
||||||
|
wfe.log.Warning(fmt.Sprintf("Could not write response: %s", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue