diff --git a/lib/forever/monitor.js b/lib/forever/monitor.js index 49d16502..d6e719e5 100644 --- a/lib/forever/monitor.js +++ b/lib/forever/monitor.js @@ -394,17 +394,20 @@ Monitor.prototype.watch = function () { Array.prototype.push.apply(self.watchIgnorePatterns, data.split('\n')); }); - watch.createMonitor( - this.watchDirectory, - function (monitor) { - monitor.on('changed', function (f, curr, prev) { - if (self._watchFilter(f)) { - self.info('restaring script because ' + f + ' changed'); - self.restart(); - } - }); - } - ); + watch.watchTree(this.watchDirectory, function (f, curr, prev) { + if (!(curr == null && prev == null && typeof f == 'object')) { + // + // `curr` == null && `prev` == null && typeof f == "object" when watch + // finishes walking the tree to add listeners. We don't need to know + // about it, so we simply ignore it (anything different means that + // some file changed/was removed/created - that's what we want to know). + // + if (self._watchFilter(f)) { + self.info('restaring script because ' + f + ' changed'); + self.restart(); + } + }; + }); }; //