Reputation: 279
I have an array of JSON objects which gets updated at server start, however if I change info in the JSON via NodeJS FS (not by doing it myself) Nodemon doesn't restart, so I was wondering if it is possible to restart nodemon via code.
Upvotes: 3
Views: 1324
Reputation: 7666
You need to specify the watch list as by default it will monitor only js and coffee files. You do that by --ext switch or -e
nodemon -e js,json
If you have typescript files too to worry about add them above
Upvotes: 0
Reputation: 21354
Not sure I fully understand the question, but yes, you can send the nodemon process a SIGHUP signal, e.g.:
pkill -f -SIGHUP nodemon
And you could call this from node.js using child_process.exec. Here is a working example:
const exec = require('child_process').exec;
setTimeout(() => {
console.log('poking nodemon to restart');
exec('pkill -f -SIGHUP nodemon');
}, 2000);
Upvotes: 3