From cf35038644c1cca2b1d522413ce4ff97d1e8b340 Mon Sep 17 00:00:00 2001 From: Makis Maropoulos Date: Fri, 1 Jul 2016 19:20:27 +0300 Subject: [PATCH] Available runs in goroutine for .NoListen in order to no need the allocated Available channel --- initiatory.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/initiatory.go b/initiatory.go index b9794dd7..b5a26ba6 100644 --- a/initiatory.go +++ b/initiatory.go @@ -27,7 +27,7 @@ var ( HTTPServer *Server // Available is a channel type of bool, fired to true when the server is opened and all plugins ran // fires false when .Close is called manually. - // the channel is always on until you close it when you don't need this. + // the channel is always oepen until you close it when you don't need this. // // Note: it is a simple channel and decided to put it here and no inside HTTPServer, doesn't have statuses just true and false, simple as possible // Where to use that? @@ -98,7 +98,7 @@ func New(cfg ...config.Iris) *Framework { // we always use 's' no 'f' because 's' is easier for me to remember because of 'station' // some things never change :) - s := &Framework{Config: &c, Available: make(chan bool, 1)} // 1 because the Available can be used after the .NoListen (which is a blocking func) + s := &Framework{Config: &c, Available: make(chan bool)} { ///NOTE: set all with s.Config pointer // set the Logger @@ -204,7 +204,9 @@ func (s *Framework) justServe(optionalAddr ...string) *Server { s.Plugins.DoPreListen(s) s.HTTPServer.SetHandler(s.mux) s.Plugins.DoPostListen(s) - s.Available <- true + go func() { + s.Available <- true + }() return s.HTTPServer }