openimsdk/open-im-server · info
signal %s
Error message
signal %s
What it means
In Start, a goroutine watches SIGTERM/SIGINT; when one arrives it cancels the root context with a cause error 'signal <name>'. This error is the cancellation cause, not an internal fault — it is how the process communicates why it is shutting down (via context.Cause).
Source
Thrown at pkg/common/startrpc/start.go:171
grpccli.GrpcClientLogger(),
grpccli.GrpcClientContext(),
grpccli.GrpcClientErrorConvert(),
)
if len(clientOptions) > 0 {
client.AddOption(clientOptions...)
}
ctx, cancel := context.WithCancelCause(ctx)
go func() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT)
select {
case <-ctx.Done():
return
case val := <-sigs:
log.ZDebug(ctx, "recv signal", "signal", val.String())
cancel(fmt.Errorf("signal %s", val.String()))
}
}()
if prometheusListenAddr != "" {
options = append(
options,
prommetricsUnaryInterceptor(rpcRegisterName),
prommetricsStreamInterceptor(rpcRegisterName),
)
prometheusListener, prometheusPort, err := listenTCP(prometheusListenAddr)
if err != nil {
return err
}
log.ZDebug(ctx, "prometheus start", "addr", prometheusListener.Addr(), "rpcRegisterName", rpcRegisterName)
target, err := jsonutil.JsonMarshal(prommetrics.BuildDefaultTarget(registerIP, prometheusPort))
if err != nil {
return err
}View on GitHub (pinned to 175a7bb067)
Solutions
- No fix needed — this is the expected graceful shutdown path.
- Use context.Cause(ctx) after shutdown to log the reason; treat 'signal terminated/interrupt' as normal exit.
- If shutdown is unexpected, check what sent the signal: Kubernetes events (OOM/liveness kill shows as different exit reason), systemd, or local terminal.
- Ensure signal handling completes cleanup before exit since ctx is cancelled immediately on signal.
Defensive patterns
Strategy: try-catch
Try / catch
err := start(ctx)
if cause := context.Cause(ctx); cause != nil {
var sigErr *fmt.wrapError // or string-match on "signal "
if strings.HasPrefix(cause.Error(), "signal ") {
log.Info("graceful shutdown", "cause", cause)
return nil
}
} Prevention
- Treat 'signal terminated'/'signal interrupt' causes as normal exit code 0
- Distinguish Kubernetes SIGTERM (rollout) from crashes via exit reason
- Ensure cleanup runs promptly after context cancellation
When it happens
Trigger: The process receives SIGTERM (e.g. kubectl delete pod, systemd stop, docker stop) or SIGINT (Ctrl+C) while the RPC server is running.
Common situations: Normal graceful shutdown in Kubernetes (SIGTERM on pod termination); developer pressing Ctrl+C locally; orchestrator restarts; logs/context.Cause then surface 'signal terminated' or 'signal interrupt'.
Related errors
AI-assisted analysis of openimsdk/open-im-server@175a7bb067 (2026-09-04).
Data as JSON: /api/errors/0dd94e91f1b1e0b9.
Report an issue: GitHub.