I
I
igamity2012-07-31 21:49:59
Node.js
igamity, 2012-07-31 21:49:59

How to start independent process from node?

Good afternoon!

The essence of the question is the following, how to start a new process from the node.js process, which will continue to run even after the termination of the node?

In details. There is a controller process that should run processes that interact with TCP sockets. New processes should be launched in such a way that even after the controller process is closed, they would remain alive and restarting the controller should pick up existing processes and continue to manage them: kill, create new ones, etc.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
U
unclechu, 2012-08-01
@unclechu

#!/usr/bin/env node require('child_process').exec('name &', function (err) { if (err) { console.log('Can\'t start child process.'); process.exit(1); } console.log('Child process is started.'); });

U
unclechu, 2012-08-01
@unclechu

#!/usr/bin/env node

require('child_process').exec('name &', function (err) {
  if (err) {
    console.log('Can\'t start child process.');
    process.exit(1);
  }

  console.log('Child process is started.');
});

1
1nd1go, 2012-08-01
@1nd1go

Try what unclechu wrote, just require('child_process').spawn

1
1nd1go, 2012-08-01
@1nd1go

Try what unclechu wrote, just require('child_process').spawn

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question