api.route('/allsearch')
.post(function(req,res){
var filters=req.body.everything;
var filterid=req.body.filterId;
var searchid=req.body.searchid;
var zipgroup=req.body.zipgroup;
var myObject = new Array();
Searchfinal.update({searchfilterid:filterid},{$set:{consumed:0}}, function(err, resu){
var asyncTasks = [];
zipgroup.forEach(function(item){
asyncTasks.push(function(callback){
searchingalgo(item, filters, filterid, function(pers){
myObject[item] = pers;
callback();
});
});
});
Async.parallel(asyncTasks, function(){
}); //getdata function
res.json({
suceess: true,
message: 'Precess Started'
});
});
});
zipgroup是一个拉链数组,请求的格式如
{"everything":{"zip":37664,"radius":10,"GENDER":"","HH_INCOME":"","NET_WORTH":"","OCC_OCCUP":"","ac":"ADULTS_F_18_24":true},"child":"","HH_INCOME_VALUE":""},"searchid":"56acf3517f690df311344b14","filterId":"56acf3547f690df311344b15","zipgroup":["37615"," 37663"," 37662"," 37669"," 37664"," 37617"," 37660"," 37645"," 37665"," 24290"," 24258"," 37615"," 37265"," 24230"," 14258"]}
问题是它一次只运行5个进程,不超过5个。
> db.currentOp().inprog.length
5
这是shell上的输出