From f7cf7f7a5092cab62a68a803ecc221a43dea96dd Mon Sep 17 00:00:00 2001 From: lsm Date: Tue, 27 Oct 2015 23:30:15 -0700 Subject: [PATCH] Delay set http server to allow listeners in the promise chain will get the `server` event. --- lib/service/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/service/index.js b/lib/service/index.js index 1778617..94259c1 100644 --- a/lib/service/index.js +++ b/lib/service/index.js @@ -164,7 +164,10 @@ Service.prototype.startWebServer = function(port, host) { self.announcement.webPort = address.port debug('[%s] web server started at %s:%s', self.name, address.address, address.port) - self.setHttpServer(server) + // Make sure listeners in `init()` could get this event. + process.nextTick(function() { + self.setHttpServer(server) + }) } }) }