@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -51,7 +51,9 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
runtime.WithRegistry(reg),
|
||||
runtime.WithTraceProvider(traceProvider),
|
||||
)
|
||||
|
||||
logger.Info().
|
||||
Str("server", cfg.Service.Name).
|
||||
Msg("reva runtime exited")
|
||||
return nil
|
||||
}, func(err error) {
|
||||
logger.Error().
|
||||
@@ -60,7 +62,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -74,6 +75,9 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
gr.Add(debugServer.ListenAndServe, func(_ error) {
|
||||
logger.Info().
|
||||
Str("server", cfg.Service.Name).
|
||||
Msg("Shutting down debug erver")
|
||||
cancel()
|
||||
})
|
||||
|
||||
@@ -86,14 +90,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user