I am setting up a nodejs server using grunt as the task runner, so I have many grunt tasks that do various things. Many of them handle signals like SIGINT, SIGQUIT, and SIGTERM. Until I add the line grunt.loadNpmTasks('grunt-nodemon'); to my Gruntfile, all of these signal handlers worked fine. As soon as I add that line, other grunt tasks, unrelated to nodemon, no longer handle signals properly.
For reproducing the issue, make sure the line I indicated above is commented out in your Gruntfile. You do not need to remove the initConfig info, or uninstall grunt-nodemon from node_modules. Then create a simple grunt task that handles SIGINT like so:
Run that task, then press Ctrl-C to send the SIGINT signal to the process, and you should see that the task exits properly, displaying the desired text before exiting.
Now if you uncomment grunt.loadNpmTasks('grunt-nodemon'); in the Gruntfile and try to run the example task again, you will see that it no longer handles the signal properly.
Why would having grunt-nodemon affect other unrelated grunt tasks?
I think that is 'by design' (hard to explain though). A workaround for this is to use grunt-concurrent, e.g. you can see an example of usage here. Haven't tried it - so it might not be applicable for your case.
I am setting up a nodejs server using grunt as the task runner, so I have many grunt tasks that do various things. Many of them handle signals like SIGINT, SIGQUIT, and SIGTERM. Until I add the line
grunt.loadNpmTasks('grunt-nodemon');
to my Gruntfile, all of these signal handlers worked fine. As soon as I add that line, other grunt tasks, unrelated to nodemon, no longer handle signals properly.For reproducing the issue, make sure the line I indicated above is commented out in your Gruntfile. You do not need to remove the initConfig info, or uninstall grunt-nodemon from
node_modules
. Then create a simple grunt task that handles SIGINT like so:Run that task, then press Ctrl-C to send the SIGINT signal to the process, and you should see that the task exits properly, displaying the desired text before exiting.
Now if you uncomment
grunt.loadNpmTasks('grunt-nodemon');
in the Gruntfile and try to run the example task again, you will see that it no longer handles the signal properly.Why would having grunt-nodemon affect other unrelated grunt tasks?