mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 12:06:37 +00:00
Rename marshal_request for watchdog, enable lock-file for healthcheck CMD.
This commit is contained in:
@ -22,9 +22,9 @@ func buildFunctionInput(config *WatchdogConfig, r *http.Request) ([]byte, error)
|
|||||||
|
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
requestBytes, _ = ioutil.ReadAll(r.Body)
|
requestBytes, _ = ioutil.ReadAll(r.Body)
|
||||||
if config.marshallRequest {
|
if config.marshalRequest {
|
||||||
marshalRes, marshallErr := types.MarshalRequest(requestBytes, &r.Header)
|
marshalRes, marshalErr := types.MarshalRequest(requestBytes, &r.Header)
|
||||||
err = marshallErr
|
err = marshalErr
|
||||||
res = marshalRes
|
res = marshalRes
|
||||||
} else {
|
} else {
|
||||||
res = requestBytes
|
res = requestBytes
|
||||||
@ -135,5 +135,12 @@ func main() {
|
|||||||
|
|
||||||
http.HandleFunc("/", makeRequestHandler(&config))
|
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())
|
log.Fatal(s.ListenAndServe())
|
||||||
}
|
}
|
||||||
|
@ -57,9 +57,9 @@ func (ReadConfig) Read(hasEnv HasEnv) WatchdogConfig {
|
|||||||
|
|
||||||
cfg.writeDebug = parseBoolValue(hasEnv.Getenv("write_debug"))
|
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.debugHeaders = parseBoolValue(hasEnv.Getenv("debug_headers"))
|
||||||
|
cfg.suppressLock = parseBoolValue(hasEnv.Getenv("suppress_lock"))
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,8 +74,11 @@ type WatchdogConfig struct {
|
|||||||
// writeDebug write console stdout statements to the container
|
// writeDebug write console stdout statements to the container
|
||||||
writeDebug bool
|
writeDebug bool
|
||||||
|
|
||||||
marshallRequest bool
|
marshalRequest bool
|
||||||
|
|
||||||
// prints out all incoming and out-going HTTP headers
|
// prints out all incoming and out-going HTTP headers
|
||||||
debugHeaders bool
|
debugHeaders bool
|
||||||
|
|
||||||
|
// Don't write a lock file to /tmp/
|
||||||
|
suppressLock bool
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user