-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
executable file
·79 lines (64 loc) · 2.19 KB
/
app.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
var pomelo = require('pomelo');
var routeUtil = require('./app/util/routeUtil');
var abuseFilter = require('./app/util/abuseFilter');
var httpPlugin = require('pomelo-http-plugin');
var path = require('path');
/**
* Init app for client.
*/
var app = pomelo.createApp();
app.set('name', 'chatofpomelo');
var logger = require('pomelo-logger');
logger.configure(app.getBase()+'/config/log4js.json', {
serverId: app.getServerId(),
base: app.getBase()
});
// app configure
app.configure('production|development|backup|scale', function() {
// route configures
app.route('chat', routeUtil.chatConsistentHash);
// filter configures
app.filter(pomelo.timeout());
app.set('connectorConfig', {
connector : pomelo.connectors.hybridconnector,
useDict : true,
useProtobuf : true,
heartbeat : 15,
disconnectOnTimeout : false,
setNoDelay : true
});
app.set('errorHandler', function (err, msg, resp, session, next) {
console.log(err, msg, resp, session);
next();
});
app.loadConfigBaseApp('redis', 'redis.json');
app.loadConfigBaseApp('forbid', 'forbid.json');
});
app.configure('production|development|backup|scale', 'master', function() {
app.set('ssh_config_params', ['-p 4344', '-o Host=*', '-o GSSAPIAuthentication=no', '-o HashKnownHosts=no', '-o CheckHostIP=no', '-o StrictHostKeyChecking=no']);
});
app.configure('production|development|backup|scale', 'chat', function() {
var chatRedisClient = require('./app/dao/redis/redis').init(app);
app.set('chatRedisClient', chatRedisClient);
app.filter(abuseFilter(app));
});
// http消息接口
app.configure('production|development|backup|scale', 'httpchat', function() {
app.loadConfigBaseApp('httpConfig', 'http.json');
app.use(httpPlugin, {
http: app.get('httpConfig')[app.getServerType()]
});
});
// 安全策略
/*app.configure('production|development|backup|scale', 'connector', function() {
app.set('proxyConfig', {
failMode : 'failsafe',
retryTimes : 3,
retryConnectTime : 5000
});
});*/
// start app
app.start();
process.on('uncaughtException', function(err) {
console.error(' Caught exception: ' + err.stack);
});