diff --git a/package.json b/package.json index 6d0840a..07a541e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "anyproxy", - "version": "2.8.3", + "version": "2.8.4", "description": "A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.", "main": "proxy.js", "bin": { diff --git a/proxy.js b/proxy.js index 1e7ae92..62f7b52 100644 --- a/proxy.js +++ b/proxy.js @@ -150,8 +150,14 @@ function proxyServer(option){ //TODO : uncaught exception //kill web server when father process exits - process.on("exit uncaughtException",function(){ + process.on("exit",function(code){ child_webServer.kill(); + console.log('AnyProxy is about to exit with code:', code); + process.exit(); + }); + process.on("uncaughtException",function(err){ + child_webServer.kill(); + console.log('Caught exception: ' + err); process.exit(); });