I am creating a library that will start a process which then forks child_processes; it's much like using the cluster module with a server, except in my case neither the parent/master nor the child_processes are servers.
What I need to do is be able to give the user the option of killing the process once the whole thing starts. The only way I know of doing this, is to have the parent process listen on a specific port. Then I can communicate with the parent process, and it can be responsible for killing the child_processes.
The one problem with this, is if the user runs two or more different process groups side-by-side, then I would have to increment the port that each one listens on, and then the user doesn't actually know what the ports are anymore.
Does anyone know about the problem I am trying to solve and is there a good solution for this situation?
If I end up listening on a specific port, should I use the net module from core Node? Probably the net.Socket() option https://nodejs.org/api/net.html#net_class_net_socket
Seems like I need to make this process into a server so that it can listen on a port and easily receive messages.