-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send Message Via Nodemon #1519
Comments
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. |
Bump! |
By "send message" - can you be more specific? What exactly do you want to send? |
@remy Kind of like emitting events to a child process. https://medium.com/@NorbertdeLangen/communicating-between-nodejs-processes-4e68be42b917 Something like this but the events should go to my server such that I can tell it to hot swap the module instead of restarting |
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. |
Bump! |
@remy Any thoughts on this issue? |
Your original reply didn't really answer my question.
nodemon supports postMessage for RPC, but your slim example is two things: 1) don't restart, 2) "this" What is "this" supposed to be. Can you provide an example of exactly what you would like to do? |
Sorry for the late response. So here is my use case: I am working on a "framework"/library for my app where it will hot-swap certain modules so the server doesn't have to restart (boot-time is a few seconds) only in development mode. I would however like to use Here is how I start the server in my CLI program: 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',
}); Notice how I ignore the routes folder. I then set up chokidar to watch the routes folder manually: chokidar.watch(
path.join(cwd, './src/routes', `**/*.js`),
{
ignored: /(^|[\/\\])\../, // ignore dot files
}
).on('change', (path) => {
if (shouldFullyRestartServer) {
nodemon.restart(); // great
} else {
# HERE
}
}); Where it says HERE, I want to tell the child process which is running Maybe there is a simpler solution that I can't see, but basically, I would like the ability for the parent process running nodemon via script to be able to send messages to the child process that nodemon starts. Thanks! |
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. |
Okay, I can follow your code example. You want to push the message directly into the child but it needs to go via nodemon. I think I can see how that would work. I'll have to come back to you (though the stalebot will keep trying to close this issue - sorry!) |
Hey! Thank you! I think the opposite should also work (and I might need it for that specific use case). If the child emits an event, nodemon could capture it and add a "event" hook or something that the parent can listen on. Thanks, |
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. |
bump! |
add event to listen to messages coming from the child's ipc events, partially implementing remy#1519
add event to listen to messages coming from the child's ipc events, partially implementing #1519
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. |
Bump (because it looks like there is some progress being made). Unfortunately I don't need this feature anymore (I ended up with a better solution) but hopefully, someone finds this useful. Thank you! |
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. |
nodemon -v
:1.18.9node -v
:10.14.2required
version 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
--dump
flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.The text was updated successfully, but these errors were encountered: