From 0b3463701dfb454ea7659df1d32d8294e5ee93c4 Mon Sep 17 00:00:00 2001 From: Mike Angstadt Date: Mon, 17 Nov 2014 09:20:44 -0600 Subject: [PATCH] Implemented mixdown-server .stop() method Added support for stopping a mixdown server to support unit testing of single-app instantiation. --- index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ddd262d..00c5f4a 100644 --- a/index.js +++ b/index.js @@ -61,7 +61,19 @@ Main.prototype.createMaster = function(callback) { }; Main.prototype.stop = function(callback) { - throw new Error('stop() not implemented on server. TODO.'); + var self = this; + + if (self.workers) { + _.each(self.workers, function(child) { + child.destroy(); // send suicide signal + }); + } + + self.server.on("close", function() { + callback(); + }); + + self.server.close(); }; Main.prototype.start = function(callback) {