Skip to content

Commit

Permalink
[api] simplest possible file watcher (ref #41)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalecki committed Sep 30, 2011
1 parent d658ee3 commit fff672d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/forever/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var util = require('util'),
events = require('events'),
spawn = require('child_process').spawn,
winston = require('winston'),
watch = require('watch'),
forever = require('../forever');

//
Expand Down Expand Up @@ -364,6 +365,21 @@ Monitor.prototype.kill = function (forceStop) {
return this;
};

//
// ### function watch ()
// Starts watching directory tree for changes.
//
Monitor.prototype.watch = function () {
var self = this;

watch.createMonitor(process.cwd(), {ignoreDotFiles: true}, function (monitor) {
monitor.on('changed', function (f, curr, prev) {
self.info('restaring script because ' + f + ' changed');
self.restart();
});
});
}

//
// ### @private function _getEnv ()
// Returns the environment variables that should be passed along
Expand Down

0 comments on commit fff672d

Please sign in to comment.