-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbirdway.js
106 lines (87 loc) · 3.31 KB
/
birdway.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* Author: DolphinBoy
* Email: [email protected]
* Date: 12-7-10
* Time: 10:21
* 主程序入口
* 注意加载的顺序,不能随便更改
* 加载配置文件、定义全局变量,初始化控制器,自定义错误处理
*/
//==================定义全局静态变量==================
global.BASEDIR = __dirname;
global.STATIC = {
PUBLIC : global.BASEDIR + '/public',
VIEW : global.BASEDIR + '/view',
LOG : global.BASEDIR + '/log'
};
//--------模块引入(系统模块)--------
global.Module = {
fs : require('fs'),
path : require('path'),
url : require('url'),
util : require('util'),
qs : require('querystring'),
cp : require('child_process'),
http : require('http'),
sio : require('socket.io')
//gzippo : require('gzippo') //压缩静态文件
// parseCookie : require('connect').utils.parseCookie,
// MemoryStore : require('connect/middleware/session/memory')
};
//--------返回结果--------
global.RESULT = {
status : 'status',
failed : 'failed',
success : 'success',
error : 'error',
msg : 'msg',
command : 'command',
ext : 'ext',
datatime :'datatime'
};
//==================创建服务器==================
var express = require('express');
//gzippo = require('gzippo'),
// sios = require('socket.io-sessions'),
// RedisStore = require('connect-redis')(express);
// parseCookie = require('connect').utils.parseCookie,
// MemoryStore = require('connect/lib/middleware/session/memory');
//var server = module.exports = express.createServer();
//var server = module.exports = express();
var server = express();
//创建server之前是否需要调用服务配置方法呢?
//var httpserver = module.exports = global.Module.http.createServer(server);
var httpserver = global.Module.http.createServer(server);
var io = global.Module.sio.listen(httpserver);
//==================加载配置文件==================
//var yaml = require('yaml-config');
//global.requestsinaip = yaml.readConfig('config/serverconfig.yaml');
//global.requestsinaip = yaml.readConfig('config/serverconfig.yaml', 'sinaip');
global.siteconfig = require('./config/site_config').siteconfig;
global.dbconfig = require('./config/site_config').dbconfig;
global.mailconfig = require('./config/site_config').mailconfig;
global.requestip = require('./config/requestip'); //xxxxx要归到系统配置目录里面xxxxx
//global.dbconfig = require('./server_config').dbconfig;
//global.mailconfig = require('./server_config').mailconfig;
//global.emailsite = require('./server_config').emailsite;
//==================the end==================
// 配置服务参数
require('./config').boot(server, express);
// 模块中间路由
global.Middle = require('./middle'); //这一行代码必须要放在服务器配置函数之后,路由函数之前
// 配置路由
require('./router').boot(server);
//server.get('/', function(req, res){
// req.redirect("./static/index.html");
//})
//server.get('*', function(){
// console.log('get url!');
//});
//错误处理
//require('./error').boot(server, express);
httpserver.listen(8088, function(){ //这地方可以指定监听的IP吧
// console.log("Express server listening on port %d in %s mode", server.address().port, server.settings.env);
console.log("Express server listening on port 8088");
});
// 配置websocket
require('./websocket').boot(io);