找到了一个可以
node.js从应用本身重新启动的工作案例:
例:
// Optional part (if there's an running webserver which blocks a port required for next startuptry { APP.webserver.close(); // Express.js instance APP.logger("Webserver was halted", 'success');} catch (e) { APP.logger("Cant't stop webserver:", 'error'); // No server started APP.logger(e, 'error');}// First I create an exec command which is executed before current process is killedvar cmd = "node " + APP.config.settings.ROOT_DIR + 'app.js';// Then I look if there's already something ele killing the process if (APP.killed === undefined) { APP.killed = true; // Then I excute the command and kill the app if starting was successful var exec = require('child_process').exec; exec(cmd, function () { APP.logger('APPLICATION RESTARTED', 'success'); process.kill(); });}我在这里看到的唯一缺点是在控制台上松开了输出,但是如果将任何内容记录到日志文件中,这不是问题。



