From e2ee6c996a5bc4ebcdb27bcf8619542d2dc8ed85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8A=A0=E9=87=8C?= <xiaofeng.mxf@taobao.com>
Date: Mon, 22 Sep 2014 13:59:23 +0800
Subject: [PATCH] recover tips for web server

---
 lib/rule_default.js | 2 +-
 package.json        | 2 +-
 proxy.js            | 8 ++++++++
 webServer.js        | 2 --
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/rule_default.js b/lib/rule_default.js
index f4fe3d3..ac459cf 100644
--- a/lib/rule_default.js
+++ b/lib/rule_default.js
@@ -2,7 +2,7 @@ var isRootCAFileExists = require("./certMgr.js").isRootCAFileExists();
 
 module.exports = {
     summary:function(){
-        var tip = "the default rule for anyproxy, support : CORS";
+        var tip = "the default rule for anyproxy, support : CORS. ";
         if(isRootCAFileExists){
             tip += "\nRoot CA exists, will intercept all https requests for you";
         }
diff --git a/package.json b/package.json
index 4243323..137f4bc 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "anyproxy",
-  "version": "2.4.3",
+  "version": "2.4.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 2863cfd..9fd6514 100644
--- a/proxy.js
+++ b/proxy.js
@@ -119,6 +119,11 @@ function proxyServer(option){
                     }
                 });
 
+                //kill web server when father process exits
+                process.on("exit",function(){
+                    child_webServer.kill(); 
+                });
+
                 GLOBAL.recorder.on("update",function(data){
                     child_webServer.send({
                         type: "update",
@@ -131,6 +136,9 @@ function proxyServer(option){
                     console.log(arguments);
                 })
 
+                var tipText = "web interface started at port " + proxyWebPort;
+                console.log(color.green(tipText));
+
                 callback(null);
             }
         ],
diff --git a/webServer.js b/webServer.js
index 861f197..2ee84ef 100644
--- a/webServer.js
+++ b/webServer.js
@@ -63,8 +63,6 @@ function proxyWebServer(port,webSocketPort,proxyConfigPort,ruleSummary,recorder)
 
     app.listen(port);
 
-    var tipText = "web interface started at port " + port;
-
     //web socket interface
     var wss = new WebSocketServer({port: webSocketPort});
     wss.on("connection",function(ws){});