diff --git a/is-master.js b/is-master.js index de2840d..19b0663 100644 --- a/is-master.js +++ b/is-master.js @@ -6,6 +6,8 @@ var mongoose = require('mongoose'), EventEmitter = require("events").EventEmitter, os = require('os'); +var itv; + function im() { EventEmitter.call(this); } @@ -40,6 +42,10 @@ im.prototype.start = function(options) { this.startWorker(); }; +im.prototype.stop = function () { + clearInterval(itv); +}; + /** * Function initializes the mongoose table, schema, and model */ @@ -133,7 +139,7 @@ im.prototype.startWorker = function() { im.prototype.process = function() { var _this = this; // Update this node in the cluster every x timeout - setInterval(function() { + itv = setInterval(function() { _this.imModel.updateOne({ _id: _this.id }, {