您必须使用readline模块并监听SIGINT事件:
http://nodejs.org/api/readline.html#readline_event_sigint
if (process.platform === "win32") { var rl = require("readline").createInterface({ input: process.stdin, output: process.stdout }); rl.on("SIGINT", function () { process.emit("SIGINT"); });}process.on("SIGINT", function () { //graceful shutdown process.exit();});


