mirror of https://github.com/hak5/overseer.git
expose overseer sanity check (closes #9), remove beta warning
parent
ab80a24f26
commit
420ec56f3a
|
@ -8,8 +8,6 @@
|
|||
|
||||
Commonly, graceful restarts are performed by the active process (*dark blue*) closing its listeners and passing these matching listening socket files (*green*) over to a newly started process. This restart causes any **foreground** process monitoring to incorrectly detect a program crash. `overseer` attempts to solve this by using a small process to perform this socket file exchange and proxying signals and exit code from the active process.
|
||||
|
||||
:warning: *`overseer` is being used heavily at my workplace and no major issues have yet to be found. Nevertheless, consider it beta software and please report any [issues](https://github.com/jpillora/overseer/issues) you encounter.*
|
||||
|
||||
### Features
|
||||
|
||||
* Simple
|
||||
|
|
47
overseer.go
47
overseer.go
|
@ -107,29 +107,50 @@ func Run(c Config) {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
//sanityCheck returns true if a check was performed
|
||||
func sanityCheck() bool {
|
||||
//sanity check
|
||||
if token := os.Getenv(envBinCheck); token != "" {
|
||||
fmt.Fprint(os.Stdout, token)
|
||||
return true
|
||||
}
|
||||
//legacy sanity check using old env var
|
||||
if token := os.Getenv(envBinCheckLegacy); token != "" {
|
||||
fmt.Fprint(os.Stdout, token)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
//SanityCheck manually runs the check to ensure this binary
|
||||
//is compatible with overseer. This tries to ensure that a restart
|
||||
//is never performed against a bad binary, as it would require
|
||||
//manual intervention to rectify. This is automatically done
|
||||
//on overseer.Run() though it can be manually run prior whenever
|
||||
//necessary.
|
||||
func SanityCheck() {
|
||||
if sanityCheck() {
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
//abstraction over master/slave
|
||||
var currentProcess interface {
|
||||
triggerRestart()
|
||||
run() error
|
||||
}
|
||||
|
||||
func runErr(c *Config) error {
|
||||
if err := validate(c); err != nil {
|
||||
return err
|
||||
}
|
||||
//sanity check
|
||||
if token := os.Getenv(envBinCheck); token != "" {
|
||||
fmt.Fprint(os.Stdout, token)
|
||||
return nil
|
||||
}
|
||||
//legacy sanity check using old env var
|
||||
if token := os.Getenv(envBinCheckLegacy); token != "" {
|
||||
fmt.Fprint(os.Stdout, token)
|
||||
return nil
|
||||
}
|
||||
//os not supported
|
||||
if !supported {
|
||||
return fmt.Errorf("os (%s) not supported", runtime.GOOS)
|
||||
}
|
||||
if err := validate(c); err != nil {
|
||||
return err
|
||||
}
|
||||
if sanityCheck() {
|
||||
return nil
|
||||
}
|
||||
//run either in master or slave mode
|
||||
if os.Getenv(envIsSlave) == "1" {
|
||||
currentProcess = &slave{Config: c}
|
||||
|
|
Loading…
Reference in New Issue