mirror of
https://github.com/kataras/iris.git
synced 2025-02-09 02:34:55 +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.
|
// 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
|
// 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) {
|
func Run(addr string, timeout time.Duration, s *iris.Framework) {
|
||||||
|
s.HTTPServer.Config.ListeningAddr = addr
|
||||||
srv := &Server{
|
srv := &Server{
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
Logger: s.Logger,
|
Logger: s.Logger,
|
||||||
station: s,
|
station: s,
|
||||||
Server: s.NoListen(),
|
Server: s.NoListen(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := srv.listenAndServe(); err != nil {
|
if err := srv.listenAndServe(); err != nil {
|
||||||
if opErr, ok := err.(*net.OpError); !ok || (ok && opErr.Op != "accept") {
|
if opErr, ok := err.(*net.OpError); !ok || (ok && opErr.Op != "accept") {
|
||||||
srv.Logger.Fatal(err)
|
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
|
// Unlike Run this version will not exit the program if an error is encountered but will
|
||||||
// return it instead.
|
// return it instead.
|
||||||
func RunWithErr(addr string, timeout time.Duration, s *iris.Framework) error {
|
func RunWithErr(addr string, timeout time.Duration, s *iris.Framework) error {
|
||||||
|
s.HTTPServer.Config.ListeningAddr = addr
|
||||||
srv := &Server{
|
srv := &Server{
|
||||||
Timeout: timeout,
|
Timeout: timeout,
|
||||||
Logger: s.Logger,
|
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.
|
// ListenAndServe is equivalent to iris.Listen with graceful shutdown enabled.
|
||||||
func (srv *Server) listenAndServe() error {
|
func (srv *Server) listenAndServe() error {
|
||||||
// Create the listener so we can control their lifetime
|
// Create the listener so we can control their lifetime
|
||||||
|
addr := srv.station.HTTPServer.Config.ListeningAddr
|
||||||
addr := srv.Config.ListeningAddr
|
|
||||||
if addr == "" {
|
if addr == "" {
|
||||||
addr = ":http"
|
addr = ":http"
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,6 @@ func (srv *Server) serve(listener net.Listener) error {
|
||||||
|
|
||||||
// Serve with graceful listener.
|
// Serve with graceful listener.
|
||||||
// Execution blocks here until listener.Close() is called, above.
|
// Execution blocks here until listener.Close() is called, above.
|
||||||
srv.station.NoListen()
|
|
||||||
err := srv.Server.Serve(listener)
|
err := srv.Server.Serve(listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If the underlying listening is closed, Serve returns an error
|
// If the underlying listening is closed, Serve returns an error
|
||||||
|
|
Loading…
Reference in New Issue
Block a user