mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-08-01 02:11:15 -04:00
fix(runtime): log service startup errors instead of printing them beside the log
This commit is contained in:
@@ -389,9 +389,16 @@ func Start(ctx context.Context, o ...Option) error {
|
||||
if ev.Restarting {
|
||||
l = s.Log.Error()
|
||||
}
|
||||
l.Str("event", e.String()).Str("service", ev.ServiceName).Str("supervisor", ev.SupervisorName).
|
||||
Bool("restarting", ev.Restarting).Float64("failures", ev.CurrentFailures).Float64("threshold", ev.FailureThreshold).
|
||||
Interface("error", ev.Err).Msg("service terminated")
|
||||
l = l.Str("event", e.String()).Str("service", ev.ServiceName).Str("supervisor", ev.SupervisorName).
|
||||
Bool("restarting", ev.Restarting).Float64("failures", ev.CurrentFailures).Float64("threshold", ev.FailureThreshold)
|
||||
// ev.Err is an interface{}: marshaling an error yields {} because
|
||||
// its fields are unexported, so the message has to go through Err
|
||||
if err, ok := ev.Err.(error); ok {
|
||||
l = l.Err(err)
|
||||
} else {
|
||||
l = l.Interface("error", ev.Err)
|
||||
}
|
||||
l.Msg("service terminated")
|
||||
case suture.EventBackoff:
|
||||
s.Log.Warn().Str("event", e.String()).Str("supervisor", ev.SupervisorName).Msg("service backoff")
|
||||
case suture.EventResume:
|
||||
|
||||
@@ -14,5 +14,11 @@ func DefaultApp(app *cobra.Command) *cobra.Command {
|
||||
// version info
|
||||
app.Version = fmt.Sprintf("%s (%s <%s>) (%s)", version.String, "OpenCloud GmbH", "support@opencloud.eu", version.Compiled())
|
||||
|
||||
// a failing RunE is a runtime error, not a usage error: printing it here
|
||||
// would put unstructured text next to the JSON log records, and the usage
|
||||
// block on top of it is noise. main() reports what reaches it.
|
||||
app.SilenceErrors = true
|
||||
app.SilenceUsage = true
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user