nodemon -v:1.18.9
node -v:10.14.2
- Operating system/terminal environment: MacOS High Sierra
- Using Docker? What image: No
- Command you ran: Used
required version of nodemon
So I have a weird/interesting use case of nodemon. I want to conditionally restart the server (which is possible), however the times I don't want to restart the server, I would like to send a message/event to the child process/instance of my code.
Expected behaviour
I have looked at the docs and skimmed through the source code, I don't think its possible.
Actual behaviour
Nothing happens
Steps to reproduce
Here is the code I use:
const server = nodemon({
watch: ['src'],
ext, // assume .js
ignore: [path.join(cwd, `./src/routes/**/*.${ext}`)], // i am excluding this folder so I can conditionally restart
exec, // node src/index.js
});
// this is fine
server.on('start', function () {
console.log('nodemon started');
}).on('crash', function () {
console.log('script crashed for some reason');
}).on('restart', () => {
console.log('nodemon is restarting')
})
chokidar.watch(
path.join(cwd, './src/routes', `**/*.js`),
{
ignored: /(^|[\/\\])\../, // ignore dot files
}
).on('change', (path) => {
if (something) {
nodemon.restart(); // great
} else {
nodemon.send('message', 'dont restart but do this'); // UNIMPLEMENTED/HOW DO I DO THIS?
}
});
One possible solution is to give access to the child_process that nodemon opens up.
If applicable, please append the --dump flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.
nodemon -v:1.18.9node -v:10.14.2requiredversion of nodemonSo I have a weird/interesting use case of nodemon. I want to conditionally restart the server (which is possible), however the times I don't want to restart the server, I would like to send a message/event to the child process/instance of my code.
Expected behaviour
I have looked at the docs and skimmed through the source code, I don't think its possible.
Actual behaviour
Nothing happens
Steps to reproduce
Here is the code I use:
One possible solution is to give access to the child_process that nodemon opens up.
If applicable, please append the
--dumpflag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.