mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2025-12-30 16:24:26 +00:00
Update pkg/server/manager.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
feb023ec48
commit
8adc386863
@@ -217,8 +217,14 @@ func (sm *serverManager) Remove(name string) error {
|
||||
return fmt.Errorf("server with name '%s' not found", name)
|
||||
}
|
||||
|
||||
// Stop the server if it's running
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
// Stop the server if it's running. Prefer the server's configured shutdownTimeout
|
||||
// when available, and fall back to a sensible default.
|
||||
timeout := 10 * time.Second
|
||||
if gs, ok := instance.(*gracefulServer); ok && gs.shutdownTimeout > 0 {
|
||||
timeout = gs.shutdownTimeout
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
if err := instance.Stop(ctx); err != nil {
|
||||
logger.Warn("Failed to gracefully stop server '%s' on remove: %v", name, err)
|
||||
|
||||
Reference in New Issue
Block a user