pm2-dev watch json options ignored on 2.0.7 - win7

Created on 1 Sep 2016  路  7Comments  路  Source: Unitech/pm2

I have following json conf file:

{
  "apps": [
    {
      "name": "dev-web-app",
      "script": "index.js",
      "watch": [
        "server",
        "shared",
        "srv_lib"
      ],
      "merge_logs": true,
      "env": {
        "NODE_ENV": "development",
        "NODE_PATH": ""
      },
      "exec_mode": "fork_mode"
    }
}

Then I run following command

pm2-dev start config/pm2/_development.json

Expected behaviour

I expect pm2 restarts process when files changed in following dir:

"server",
"shared",
"srv_lib"

Actual behaviour

Process is restarted when a file is changed in all project folder

Steps to reproduce

Problem is here: https://github.com/Unitech/pm2/blob/development/lib/API.js#L851-L861

command options override app options insecurely

I can fix this issue if I make this change

  appConf.forEach(function(app) {
    if (opts.only && opts.only != app.name)
      return false;
    if (opts.watch && opts.watch === true && !app.watch)
      app.watch = true;
    if (opts.ignore_watch && !app.ignore_watch) // same issue with ignore_watch
      app.ignore_watch = opts.ignore_watch;
    if (opts.instances && typeof(opts.instances) === 'number')
      app.instances = opts.instances;
    apps_name.push(app.name);
  });

Software versions used

OS         : win7
node.js    : 6.5.0
PM2        : 2.0.7
Question

All 7 comments

LGTM feel free to send a PR

@amelon I've the same problem. Can you create a PR, please?

I think it's because pm2-dev is forcing watch to true: https://github.com/Unitech/pm2/blob/master/lib/DevCli.js#L65

@danielbayerlein: hard to figure out what are the rights expectations (see @soyuka comment).
For instance I switched back to nodemon on dev because I'm facing to many issues with pm2-dev

you can try to use pm2 instead of pm2-dev with your own configuration

I think we can close the issue 馃槂

landed in dev

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FujiHaruka picture FujiHaruka  路  3Comments

xzycn picture xzycn  路  3Comments

shaunwarman picture shaunwarman  路  3Comments

morfies picture morfies  路  3Comments

rajendar38 picture rajendar38  路  3Comments