https://172.16.2.149/svn/ChinaeduCloudStatic 成教svn
http://172.16.2.149:888/#/meta/list 成教开发环境
http://172.16.4.87:8080/framework-web-conf/login.jsp#/ 成教配置中心
http://172.16.2.149:8090/ 成教Jenkins发版地址
先在dev上修改,开发环境验过了,合并trunk测试环境,要上线的任务合并到labs
新的server.js
var http=require("http");
var url = require("url");
var fs = require("fs");
var libPath = require("path");
var virtualpath = 'web-public-static/'
function serverRole(req, res){
var req_path = url.parse(req.url).path.replace(virtualpath,'').replace(/\?.*$/,'');
var filepath = __dirname + req_path;
if (req_path.indexOf('/bbs/') == 0) {
filepath = 'F:/ChinaeduCloudStatic/branches/dev' + req_path;
}
var ext = libPath.extname(filepath);//返回文件的扩展名
var contentType = "";
switch(ext){
case ".html":
contentType= "text/html";
break;
case ".js":
contentType="text/javascript";
break;
case ".css":
contentType="text/css";
break;
case ".gif":
contentType="image/gif"
break;
case ".jpg":
contentType="image/jpeg";
break;
case ".png":
contentType="image/png";
break;
case ".ico":
contentType="image/icon";
break;
default:
contentType="application/octet-stream";
}
fs.exists(filepath, function(exists){
if(exists){
fs.stat(filepath, function(err, stats){//检查一个文件是否存在
if(err){
res.writeHead(500, {'Content-Type' : 'text/html;charset=utf8'});
res.end('<div styel="color:black;font-size:22px;">server error</div>');
}else{
if(stats.isFile()){
var file = fs.createReadStream(filepath);
res.writeHead(200, {'Content-Type' : contentType});
file.pipe(res);
}else{
fs.readdir(filepath, function(err, files){
var str = '';
for(var i in files){
str += files[i] + '<br/>';
}
res.writeHead(200, {'Content-Type' : 'text/html;charset=utf8'});
res.write(str);
});
}
}
});
}else{
res.writeHead(404, {'Content-Type' : 'text/html;charset=utf8'});
res.end('<div styel="color:black;font-size:22px;">404 not found</div>');
}
});
}
var server = http.createServer(serverRole);
var server2 = http.createServer(serverRole);
server.listen('80', '127.0.0.1');//测试
server2.listen('1888','127.0.0.1');//开发 + bbs