mirror of
https://github.com/grafana/grafana.git
synced 2025-02-03 20:21:01 -06:00
Fail when server is unable to bind port (#20409)
* Server: Return error when unable to bind port * Server: Exit if a service fails * Build: Remove graceful kill from Bra config
This commit is contained in:
parent
85b7ddefc0
commit
82f4fc2783
@ -17,5 +17,3 @@ cmds = [
|
||||
["go", "run", "-mod=vendor", "build.go", "-dev", "build-server"],
|
||||
["./bin/grafana-server", "-packaging=dev", "cfg:app_mode=development"]
|
||||
]
|
||||
interrupt_timout = 5
|
||||
graceful_kill = true
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/quota"
|
||||
"github.com/grafana/grafana/pkg/services/rendering"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util/errutil"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
@ -93,8 +94,7 @@ func (hs *HTTPServer) Run(ctx context.Context) error {
|
||||
listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort)
|
||||
listener, err := net.Listen("tcp", listenAddr)
|
||||
if err != nil {
|
||||
hs.log.Debug("server was shutdown gracefully")
|
||||
return nil
|
||||
return errutil.Wrapf(err, "failed to open listener on address %s", listenAddr)
|
||||
}
|
||||
|
||||
hs.log.Info("HTTP Server Listen", "address", listener.Addr().String(), "protocol", setting.Protocol, "subUrl", setting.AppSubUrl, "socket", setting.SocketPath)
|
||||
|
@ -103,7 +103,7 @@ func (s *Server) Run() (err error) {
|
||||
s.log.Info("Initializing " + service.Name)
|
||||
|
||||
if err := service.Instance.Init(); err != nil {
|
||||
return fmt.Errorf("Service init failed: %v", err)
|
||||
return errutil.Wrapf(err, "Service init failed")
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,18 +126,21 @@ func (s *Server) Run() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := service.Run(s.context); err != nil {
|
||||
err := service.Run(s.context)
|
||||
// Mark that we are in shutdown mode
|
||||
// So no more services are started
|
||||
s.shutdownInProgress = true
|
||||
if err != nil {
|
||||
if err != context.Canceled {
|
||||
// Server has crashed.
|
||||
s.log.Error("Stopped "+descriptor.Name, "reason", err)
|
||||
} else {
|
||||
s.log.Info("Stopped "+descriptor.Name, "reason", err)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// Mark that we are in shutdown mode
|
||||
// So more services are not started
|
||||
s.shutdownInProgress = true
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user