Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用PM2监控Gruntjs任务运行程序,可能吗?_Javascript_Angularjs_Node.js_Gruntjs_Pm2 - Fatal编程技术网

Javascript 使用PM2监控Gruntjs任务运行程序,可能吗?

Javascript 使用PM2监控Gruntjs任务运行程序,可能吗?,javascript,angularjs,node.js,gruntjs,pm2,Javascript,Angularjs,Node.js,Gruntjs,Pm2,我一直在创建一个angularjs应用程序,并添加Gruntjs作为它的任务运行程序 因此,每当我尝试运行我的应用程序时,我都会转到项目目录并运行一个Grunt任务,即Grunt服务器。该命令由以下代码组成 grunt.registerTask('server', 'start a web server with extras', function (target) { if (target === 'dist') { return

我一直在创建一个angularjs应用程序,并添加Gruntjs作为它的任务运行程序

因此,每当我尝试运行我的应用程序时,我都会转到项目目录并运行一个Grunt任务,即
Grunt服务器
。该命令由以下代码组成

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服务器


因此,每当
grunt服务器
任务崩溃时,它将重新启动。。使用pm2有可能吗?因为AFAIK pm2是Node.js的生产流程管理器,所以我不知道它是否与Grunt一起工作,但我知道Gruntjs是使用npm安装的,我已经设法做到了。。显然,解决办法很简单

首先运行pm2生态系统
,它将生成一个ecosystem.json

然后用这个选项填充它

{
    "name": "management-app", //this is optional
    "script": "grunt", // the script that will be run
    "args": ["server"] //argument of the script
}
在提供了ecosystem.json的配置文件之后,只需运行

pm2启动生态系统.json
瞧!结果很好!开始喜欢这个组件了