2

I am writing an application in node that does some verification and configuration and should then launch another process and exit.

I want this new process to run in the same console window and to use the same output and accept keyboard input from the console.

Is this possible with node? I know that I can create child processes but as far as I am aware they will die when node exits.

Thanks

Roaders
  • 4,373
  • 8
  • 50
  • 71
  • as far as know it's not possible in any UNIX / Linux Base Operation System . when you run process from your code , that process become the child of your process .you have to make other process before your node process become one of the `init` child process itself then communicate between them to get the result you want . i don't know if it's possible to get them in the same console or not . – Rome Nov 15 '17 at 07:28

1 Answers1

0

You may find some help in answer at below link at stackoverflow. It suggests running the two separate scripts (one where node.js configures options for 'new process' and second where your "new process" will run) separated with '&' character in terminal.

How do you run multiple programs in parallel from a bash script?

Using it, you might need to change in your node.js script so that you could be able to run the 'new process' directly from terminal instead of launching it through node script. Just configure options through node.js script and launch the process from terminal.

Shiv
  • 3,069
  • 1
  • 24
  • 17
  • Thanks, I was aware of that solution but I was hoping for something a bit more elegant. – Roaders Nov 16 '17 at 07:16
  • Okay @Roaders, for this to be a little more elegant, you can run that command through an npm script instead of running it in terminal directly. You just need to mention that command in your package.json file of node application and in terminal -> navigate to root directory of node application -> run the command `npm run start` in terminal where `start` is the name of that package.json script. – Shiv Nov 16 '17 at 08:31