From 20e323b31dd37b296cdbbb94d13b6f187c5053fc Mon Sep 17 00:00:00 2001 From: Makis Maropoulos Date: Tue, 21 Jun 2016 16:20:22 +0300 Subject: [PATCH] #198 --- graceful/graceful.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/graceful/graceful.go b/graceful/graceful.go index c338f225..19c043be 100644 --- a/graceful/graceful.go +++ b/graceful/graceful.go @@ -72,13 +72,13 @@ type Server struct { // If timeout is 0, the server never times out. It waits for all active requests to finish. // we don't pass an iris.RequestHandler , because we need iris.station.server to be setted in order the station.Close() to work func Run(addr string, timeout time.Duration, s *iris.Framework) { + s.HTTPServer.Config.ListeningAddr = addr srv := &Server{ Timeout: timeout, Logger: s.Logger, station: s, Server: s.NoListen(), } - if err := srv.listenAndServe(); err != nil { if opErr, ok := err.(*net.OpError); !ok || (ok && opErr.Op != "accept") { srv.Logger.Fatal(err) @@ -92,6 +92,7 @@ func Run(addr string, timeout time.Duration, s *iris.Framework) { // Unlike Run this version will not exit the program if an error is encountered but will // return it instead. func RunWithErr(addr string, timeout time.Duration, s *iris.Framework) error { + s.HTTPServer.Config.ListeningAddr = addr srv := &Server{ Timeout: timeout, Logger: s.Logger, @@ -105,8 +106,7 @@ func RunWithErr(addr string, timeout time.Duration, s *iris.Framework) error { // ListenAndServe is equivalent to iris.Listen with graceful shutdown enabled. func (srv *Server) listenAndServe() error { // Create the listener so we can control their lifetime - - addr := srv.Config.ListeningAddr + addr := srv.station.HTTPServer.Config.ListeningAddr if addr == "" { addr = ":http" } @@ -143,7 +143,6 @@ func (srv *Server) serve(listener net.Listener) error { // Serve with graceful listener. // Execution blocks here until listener.Close() is called, above. - srv.station.NoListen() err := srv.Server.Serve(listener) if err != nil { // If the underlying listening is closed, Serve returns an error