mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 23:40:35 +01:00
This commit is contained in:
parent
10e8b9c964
commit
20e323b31d
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user