mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 20:29:54 -06:00
Merge pull request #1963 from owncloud/fix-1616
Stop supervisor if a service fails to start
This commit is contained in:
7
changelog/unreleased/stop-supervisor-if-failure.md
Normal file
7
changelog/unreleased/stop-supervisor-if-failure.md
Normal file
@@ -0,0 +1,7 @@
|
||||
Bugfix: Stop the supervisor if a service fails to start
|
||||
|
||||
Steps to make the supervisor fail:
|
||||
|
||||
`PROXY_HTTP_ADDR=0.0.0.0:9144 bin/ocis server`
|
||||
|
||||
https://github.com/owncloud/ocis/pull/1963
|
||||
@@ -123,16 +123,32 @@ func Start(o ...Option) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// halt listens for interrupt signals and blocks.
|
||||
halt := make(chan os.Signal, 1)
|
||||
signal.Notify(halt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
|
||||
// notify goroutines that they are running on supervised mode
|
||||
s.cfg.Mode = ociscfg.SUPERVISED
|
||||
|
||||
setMicroLogger()
|
||||
|
||||
// tolerance controls backoff cycles from the supervisor.
|
||||
tolerance := 5
|
||||
totalBackoff := 0
|
||||
|
||||
// Start creates its own supervisor. Running services under `ocis server` will create its own supervision tree.
|
||||
s.Supervisor = suture.New("ocis", suture.Spec{
|
||||
EventHook: func(e suture.Event) {
|
||||
if e.Type() == suture.EventTypeBackoff {
|
||||
totalBackoff++
|
||||
if totalBackoff == tolerance {
|
||||
halt <- os.Interrupt
|
||||
}
|
||||
}
|
||||
s.Log.Info().Str("event", e.String()).Msg(fmt.Sprintf("supervisor: %v", e.Map()["supervisor_name"]))
|
||||
},
|
||||
FailureThreshold: 5,
|
||||
FailureBackoff: 3 * time.Second,
|
||||
})
|
||||
|
||||
// reva storages have their own logging. For consistency sake the top level logging will cascade to reva.
|
||||
@@ -148,10 +164,6 @@ func Start(o ...Option) error {
|
||||
}
|
||||
rpc.HandleHTTP()
|
||||
|
||||
// halt listens for interrupt signals and blocks.
|
||||
halt := make(chan os.Signal, 1)
|
||||
signal.Notify(halt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
|
||||
l, err := net.Listen("tcp", net.JoinHostPort(s.cfg.Runtime.Host, s.cfg.Runtime.Port))
|
||||
if err != nil {
|
||||
s.Log.Fatal().Err(err)
|
||||
|
||||
Reference in New Issue
Block a user