diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nodejs/unit-http/http_server.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/nodejs/unit-http/http_server.js b/src/nodejs/unit-http/http_server.js index 2f324329..d378e410 100644 --- a/src/nodejs/unit-http/http_server.js +++ b/src/nodejs/unit-http/http_server.js @@ -451,8 +451,18 @@ Server.prototype.setTimeout = function setTimeout(msecs, callback) { return this; }; -Server.prototype.listen = function () { +Server.prototype.listen = function (...args) { this.unit.listen(); + + const cb = args.pop(); + + if (typeof cb === 'function') { + this.once('listening', cb); + } + + this.emit('listening'); + + return this; }; Server.prototype.emit_request = function (req, res) { |