Pm2: Pass output to parent when run as gulp task

Created on 13 Aug 2015  路  5Comments  路  Source: Unitech/pm2

I have a gulpfile with a pm2 task that runs in foreground mode (--no-daemon):

gulp.task('serve', function() {
  pm2.connect(true, function() {
    pm2.start({
      name: 'api',
      script: 'api.js'
    }, function() {
      console.log('pm2 started');
    });
  });
});

The application api.js started by pm2 logs output to the console, but this does not make it out to the console from which I launch gulp. This happens in both fork and cluster mode.

I can see api.js output using the pm2 logs command, but I need the output to show up in the gulp console as well. Additionally, pm2 start api.js --no-daemon correctly logs to the console. How can this be done via gulp and/or the pm2 api?

Question

Most helpful comment

gulp.task('serve', function() {
  pm2.connect(true, function() {
    pm2.start({
      name: 'api',
      script: 'api.js'
    }, function() {
      console.log('pm2 started');
      pm2.streamLogs('all', 0);
    });
  });
});

All 5 comments

:+1:

gulp.task('serve', function() {
  pm2.connect(true, function() {
    pm2.start({
      name: 'api',
      script: 'api.js'
    }, function() {
      console.log('pm2 started');
      pm2.streamLogs('all', 0);
    });
  });
});

Feel free to re-open if needed ;)

Hi all,

I've gulp task with pm2 and I want to add the debug args, my script is:

pm2.start({
script: buildConfig.serverDir + "/ServerApp.js",
"node-args": ["--debug=5858"]
}, function () {
logger.info('Server started');
});

The server started but the args debug looks like does not work?
Could you help me,

Thanks,
Dustin

Was this page helpful?
0 / 5 - 0 ratings