Skip to content

Commit

Permalink
[fix api] Expose checkFile and fix logical condition
Browse files Browse the repository at this point in the history
When `checkFile` is set to `false`, `forever` doesn't check if script
file exists. This is useful for spawning node with parameters like
`--trace-gc`:

    var forever = require('forever');

    var m = new forever.Monitor(['node', '--trace-gc', 'gc.js'], {
      checkFile: false
    });
    m.start();
  • Loading branch information
mmalecki committed Feb 13, 2012
1 parent e154a50 commit b093bfc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/forever/monitor.js
Expand Up @@ -51,6 +51,7 @@ var Monitor = exports.Monitor = function (script, options) {
this.max = options.max;
this.killTTL = options.killTTL;
this.childExists = false;
this.checkFile = options.checkFile !== false;
this.times = 0;

//
Expand Down Expand Up @@ -212,7 +213,7 @@ Monitor.prototype.start = function (restart) {
// trying to execute a script with an env: e.g. node myfile.js
//
Monitor.prototype.trySpawn = function () {
if (this.command === 'node' || (this.checkFile && !this.childExists)) {
if (this.command === 'node' && this.checkFile && !this.childExists) {
try {
var stats = fs.statSync(this.args[0]);
this.childExists = true;
Expand Down Expand Up @@ -405,4 +406,4 @@ Monitor.prototype._getEnv = function () {
});

return merged;
};
};

0 comments on commit b093bfc

Please sign in to comment.