Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.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 grunt并发和处理SIGINT_Javascript_Node.js_Concurrency_Gruntjs_Grunt Concurrent - Fatal编程技术网

Javascript grunt并发和处理SIGINT

Javascript grunt并发和处理SIGINT,javascript,node.js,concurrency,gruntjs,grunt-concurrent,Javascript,Node.js,Concurrency,Gruntjs,Grunt Concurrent,我正在努力理解在使用grunt并发并试图处理SIGINT时看到的行为,希望有人能对此有所了解。基本上:当我在函数(grunt){}声明中使用SIGINT处理程序时,为什么只有一个并发任务可以看到SIGINT 简单的设置:我使用grunt并发启动watch和nodemon任务;我的grunfile.js文件的确切并发节是: concurrent: { dev: { options: { logConcurrentOutput: true

我正在努力理解在使用grunt并发并试图处理SIGINT时看到的行为,希望有人能对此有所了解。基本上:当我在
函数(grunt){}
声明中使用SIGINT处理程序时,为什么只有一个并发任务可以看到SIGINT

简单的设置:我使用grunt并发启动watch和nodemon任务;我的
grunfile.js
文件的确切并发节是:

concurrent: {
    dev: {
        options: {
            logConcurrentOutput: true
        },
        tasks: [ 'watch', 'nodemon:dev' ]
    }
}
我想监视SIGINT,这样当我点击Ctrl+C时,我就可以清理一些作为监视任务的一部分被复制的文件。首先,在
module.exports=function(grunt){…}
函数声明之外的
grunfile.js
末尾添加了以下内容:

process.on('SIGINT', function() {
    console.log('Cleaning up after the dev server...');
    console.log(JSON.stringify(process.argv));
});
当它包含在那里并且我点击Ctrl+C时,它会运行三次——一次用于我运行的主要grunt任务(
dev
),一次用于grunt并发运行的两个任务(
watch
nodemon:dev
)。这显然不是我的本意

当我在
函数(grunt){}
方法中移动SIGINT处理程序时,当我点击Ctrl+C时,它只运行一次-对于
nodemon:dev
任务。我不明白的是,为什么看不到
watch
任务也运行它(以及启动这两个任务的主并发任务
dev
),这简直要了我的命。。。主要是因为我不想依赖这种行为,因为我无法理解它,也无法确定它在所有不同的机器上是否都是相同的

所以。。。思想?我错过了什么?谢谢