mirror of
https://github.com/owncloud/ocis.git
synced 2025-04-18 23:44:07 +03:00
work on signal handling
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
parent
dde999d5c2
commit
32287da09e
@ -6,7 +6,6 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
@ -515,7 +514,7 @@ func trap(s *Service, ctx context.Context) {
|
||||
}
|
||||
}
|
||||
s.Log.Debug().Str("service", "runtime service").Msgf("terminating with signal: %v", s)
|
||||
os.Exit(0)
|
||||
//os.Exit(0) // this seems to cause an early exit that prevents services from shitting down properly
|
||||
}
|
||||
|
||||
// pingNats will attempt to connect to nats, blocking until a connection is established
|
||||
|
@ -41,6 +41,13 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
|
||||
defer cancel()
|
||||
|
||||
gr.Add(func() error {
|
||||
<-ctx.Done()
|
||||
cancel()
|
||||
return nil
|
||||
}, func(err error) {
|
||||
})
|
||||
|
||||
gr.Add(func() error {
|
||||
pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid")
|
||||
rCfg := revaconfig.AppRegistryConfigFromStruct(cfg, logger)
|
||||
|
@ -94,7 +94,7 @@ func ListenForEvents(ctx context.Context, cfg *config.Config, l log.Logger) erro
|
||||
}
|
||||
case <-ctx.Done():
|
||||
l.Info().Msg("context cancelled")
|
||||
return ctx.Err()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/oklog/run"
|
||||
|
||||
@ -100,6 +101,13 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
|
||||
}, func(err error) {
|
||||
if err == nil {
|
||||
logger.Info().
|
||||
Str("transport", "nats").
|
||||
Str("server", cfg.Service.Name).
|
||||
Msg("letting other services deregister")
|
||||
|
||||
time.Sleep(3 * time.Second)
|
||||
|
||||
logger.Info().
|
||||
Str("transport", "nats").
|
||||
Str("server", cfg.Service.Name).
|
||||
|
Loading…
x
Reference in New Issue
Block a user