1
heiher 2014-05-27 07:16:32 +08:00 via iPhone
#!/bin/bash
while true; do # run your app in foreground done |
3
rekey 2014-05-27 15:00:07 +08:00
代码运行在
try{}catch(e){} 里试试? |
4
withinthefog 2014-05-27 18:07:47 +08:00
|
5
WildCat OP @withinthefog BAE环境 似乎不能用这个。
|
6
withinthefog 2014-05-28 10:13:11 +08:00 1
cluster.on('exit', function(worker, code, signal) {
console.log('worker %d died (%s). restarting...', worker.process.pid, signal || code); cluster.fork(); }); 要纯手写的话大概就是这个样子了,不知道你的child_process是不是用cluster模块手工创建的 可以参考node.js官方的cluster模块文档: http://nodejs.org/api/cluster.html#cluster_cluster |
7
Honwhy 2014-06-19 09:42:00 +08:00 1
楼主你需要的是这个么?
``` var cp = require('child_process'); var worker; function spawn(server, config) { worker = cp.spawn('node', [ server, config ]); worker.on('exit', function (code) { if (code !== 0) { spawn(server, config); } }); } function main(argv) { spawn('server.js', argv[0]); process.on('SIGTERM', function () { worker.kill(); process.exit(0); }); } main(process.argv.slice(2)); ``` [七天学会NodeJS](http://nqdeng.github.io/7-days-nodejs/) |