Permalink
Browse files

made file watching configurable

  • Loading branch information...
1 parent d1d2dbe commit f10e7894e839602dd1c0ba8d7d0908ca4ef40c53 @troyastorino troyastorino committed Feb 5, 2014
Showing with 24 additions and 7 deletions.
  1. +14 −0 lib/base_config.js
  2. +10 −7 lib/cluster/master.js
View
@@ -32,6 +32,20 @@ config = {
}
// Set stdout to debug log-level
, debug: false
+// List of files to watch in order to restart geddy on changes in
+// development environment
+, watch: {
+ files : [
+ '/config'
+ , '/lib'
+ , '/app/controllers'
+ , '/app/models'
+ , '/app/views'
+ , '/app/helpers'
+ ]
+, includePattern: '\\.(js|coffee|css|less|scss)$'
+, excludePattern: '\\.git|node_modules'
+}
// Use worker-process rotation
, rotateWorkers: true
// How long for a full rotation
View
@@ -196,15 +196,18 @@ Master.prototype = new (function () {
, dir = process.cwd()
, callback = function (file) {
_monitorProcesses.call(self, {manualRotate: true});
- };
+ }
+ , watchConfig = this.config.watch
+ , files = watchConfig.files
+ , opts = {
+ includePattern: new RegExp(watchConfig.includePattern)
+ , excludePattern: new RegExp(watchConfig.excludePattern)
+ };
// Watch individual files so we can compare mtimes and restart
// on code-changes
- file.watch(dir + '/config', callback);
- file.watch(dir + '/lib', callback);
- file.watch(dir + '/app/controllers', callback);
- file.watch(dir + '/app/models', callback);
- file.watch(dir + '/app/views', callback);
- file.watch(dir + '/app/helpers', callback);
+ for (var i = 0, ii = watchConfig.files.length; i < ii; i++) {
+ file.watch(dir + watchConfig.files[i], opts, callback);
+ }
};
this.init = function () {

0 comments on commit f10e789

Please sign in to comment.