I don't know if this works:

var cluster = require('cluster')

if(cluster.isMaster) {
  var workers = {}

  startWorker()
  startWorker()
  startWorker()

  process.on('exit', killWorkers)
  process.on('uncaughtException', killWorkers)

  function startWorker() {
    var worker = cluster.fork()
    workers[worker.pid] = worker
  }

  function killWorkers() {
    Object.keys(workers).forEach(function(pid) {
      workers[pid].kill()
    })
  }
}

-- o

On Thu, May 10, 2012 at 9:12 AM, Kevin Liu <[email protected]> wrote:
> I'm using core cluster in node 0.6.17. Is there a way to get worker
> processes to die if the master process dies?
>
> The specific problem: my production server is daemonized using forever. It
> appears that the master process occasionally crashes. Forever tries to bring
> the server up and now I have orphaned worker processes, a new master, and
> new associated worker processes that presumably cannot bind to the port in
> use.
>
> I saw a pull request to patch this in 0.7+, but I was hoping there was a way
> to accomodate this case in the meantime.
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en



-- 
Oliver Leics @ G+
https://plus.google.com/112912441146721682527

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to