使用PM2监控Gruntjs任务执行器,有可能吗?

我一直在创build一个angularjs应用程序,并添加Gruntjs作为它的任务亚军。

所以每当我试图运行我的应用程序,我会去项目目录,并运行一个Grunt任务是grunt server 。 该命令由以下代码组成

 grunt.registerTask('server', 'start a web server with extras', function (target) { if (target === 'dist') { return grunt.task.run(['build', 'connect:dist:keepalive']); } grunt.task.run([ 'clean:server', 'concurrent:server', 'connect:livereload', 'watch' ]); } ); 

我从项目经理那里得到了一个新的任务,用pm2来控制上面的grunt server

所以每当grunt server任务崩溃,将重新启动..是可能使用pm2? 因为AFAIK pm2是Node.js的生产过程pipe理器,所以我不知道它是否适用于Grunt,但我知道Gruntjs是使用npm

我已经设法做到了..显然,解决scheme很简单

首先运行pm2 ecosystem ,它会生成一个ecos.json

并用这个选项填充它

 { "name": "management-app", //this is optional "script": "grunt", // the script that will be run "args": ["server"] //argument of the script } 

在提供ecos.json的configuration文件后,运行

pm2 start ecosystem.json和瞧! 结果是伟大的! 开始喜欢这个组件!