From 93bdfba4b2c1b1d1a89e79cd1c170737d7571c85 Mon Sep 17 00:00:00 2001 From: Alex Ellis Date: Wed, 5 Apr 2017 08:22:52 +0100 Subject: [PATCH] Rename marshal_request for watchdog, enable lock-file for healthcheck CMD. --- watchdog/main.go | 13 ++++++++++--- watchdog/readconfig.go | 9 ++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/watchdog/main.go b/watchdog/main.go index 02c6ee20..417e054b 100644 --- a/watchdog/main.go +++ b/watchdog/main.go @@ -22,9 +22,9 @@ func buildFunctionInput(config *WatchdogConfig, r *http.Request) ([]byte, error) defer r.Body.Close() requestBytes, _ = ioutil.ReadAll(r.Body) - if config.marshallRequest { - marshalRes, marshallErr := types.MarshalRequest(requestBytes, &r.Header) - err = marshallErr + if config.marshalRequest { + marshalRes, marshalErr := types.MarshalRequest(requestBytes, &r.Header) + err = marshalErr res = marshalRes } else { res = requestBytes @@ -135,5 +135,12 @@ func main() { http.HandleFunc("/", makeRequestHandler(&config)) + if config.suppressLock == false { + writeErr := ioutil.WriteFile("/tmp/.lock", []byte{}, 0660) + if writeErr != nil { + log.Panicf("Cannot write /tmp/.lock for healthcheck: %s \n", writeErr.Error()) + } + } + log.Fatal(s.ListenAndServe()) } diff --git a/watchdog/readconfig.go b/watchdog/readconfig.go index 7c8910db..53215ce4 100644 --- a/watchdog/readconfig.go +++ b/watchdog/readconfig.go @@ -57,9 +57,9 @@ func (ReadConfig) Read(hasEnv HasEnv) WatchdogConfig { cfg.writeDebug = parseBoolValue(hasEnv.Getenv("write_debug")) - cfg.marshallRequest = parseBoolValue(hasEnv.Getenv("marshall_request")) + cfg.marshalRequest = parseBoolValue(hasEnv.Getenv("marshal_request")) cfg.debugHeaders = parseBoolValue(hasEnv.Getenv("debug_headers")) - + cfg.suppressLock = parseBoolValue(hasEnv.Getenv("suppress_lock")) return cfg } @@ -74,8 +74,11 @@ type WatchdogConfig struct { // writeDebug write console stdout statements to the container writeDebug bool - marshallRequest bool + marshalRequest bool // prints out all incoming and out-going HTTP headers debugHeaders bool + + // Don't write a lock file to /tmp/ + suppressLock bool }