update doc ,ready to push to npm

This commit is contained in:
加里
2014-08-13 17:30:16 +08:00
parent 655e15cd04
commit 9069aca226
7 changed files with 85 additions and 70 deletions

View File

@@ -41,11 +41,12 @@ function asyncTaskMgr(){
while(tmpCb = task.callbackList.shift()){
tmpCb && tmpCb.apply(null,task.result);
}
}
});
}
}
};
module.exports = asyncTaskMgr;

View File

@@ -4,7 +4,7 @@ var exec = require('child_process').exec,
fs = require("fs"),
os = require("os"),
color = require('colorful'),
asyncTask = require("./asyncTaskMgr");
asyncTask = require("async-task-mgr");
var certDir = path.join(getUserHome(),"/.anyproxy_certs/"),
cmdDir = path.join(__dirname,"..","./cert/"),
@@ -19,16 +19,16 @@ function getCertificate(hostname,cb){
crtFile = path.join(certDir , "__hostname.crt".replace(/__hostname/,hostname) );
if(!fs.existsSync(keyFile) || !fs.existsSync(crtFile)){
asyncTaskMgr.addTask(hostname,function(err){
asyncTaskMgr.addTask(hostname,function(cb){
createCert(hostname,function(err){
cb(err ? err : null);
});
},function(err){
if(!err){
cb(null , fs.readFileSync(keyFile) , fs.readFileSync(crtFile) );
}else{
cb(err);
}
},function(cb){
createCert(hostname,function(err){
cb(err ? -1 : null);
});
});
}else{

View File

@@ -8,7 +8,7 @@ var getPort = require('./getPort'),
url = require('url'),
color = require('colorful'),
certMgr = require("./certMgr"),
asyncTask = require("./asyncTaskMgr");
asyncTask = require("async-task-mgr");
var DEFAULT_RELEASE_TIME = 120*1000;
@@ -40,9 +40,10 @@ module.exports =function(){
//create server with corresponding CA
}else{
asyncTaskMgr.addTask(hostname ,userCB,function(cb){
createServer(cb);
});
asyncTaskMgr.addTask(hostname, createServer ,userCB);
// ,function(cb){
// createServer(cb);
// });
function createServer(cb){
async.series([