This repository has been archived by the owner on Jun 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsettings.js
224 lines (173 loc) · 5.71 KB
/
settings.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
//
// settings.js
//
// global definitions of common settings
// 2012-07-02 initial version
// 2013-07-25 add all src/dev/test/prod settings
// 2014-01-13 add version number starting from 0.0.4.1
// 2014-02-20 move version to global.js
// 2014-07-24 extract local-specific settings to ../config.js
//-----------------------------------------
// define global variables
//
//-----------------------------------------
// default settings
var settings = exports.settings = {
// mode can be 'dev', 'prod'
MODE: 'dev',
// IP & Domainname for Lobby
IP_LOBBY: '127.0.0.1',
DOMAIN_LOBBY: 'localhost',
//
// DB
//
DB_IP: '127.0.0.1',
DB_PORT: 27017,
DB_ADMIN: {account: 'dbadmin', pass: 'dbadmin-pass'},
// default to show error & warning only
LOG_LEVEL: 2,
// Internal DB collection name
DB_NAME_STAT: '__stat',
DB_NAME_SYSTEM: '__system',
DB_NAME_ACCOUNT: '__account',
DB_NAME_PAYMENT: '__payment',
DB_NAME_SYNC: '__sync',
DB_NAME_SYS_EVENT: '__sysevent',
//
// monitor setting
//
//~ IP_MONITOR : local_config.IP_MONITOR || local_config.IP_LOBBY,
PORT_MONITOR: 37000,
PORT_EDITOR: 443,
PORT_PROJECTS: 37030,
PORT_APP_RANGE_START: 40000, // start of the assigned port range for monitor
PORT_APP_RANGE_END: 41000, // end of assigned port range for monitor
PORT_RESERVED_SIZE: 10, // how many ports should a server reserve for itself
EMAIL_ADMIN: '', // default to none, but may be override for different server types
// interval to report app server stat to monitor server
INTERVAL_STAT_REPORT: 5000,
// interval to remove non-reporting (i.e., dead) servers from monitor's live server list
INTERVAL_LIVENESS_CHECK: 1000,
// port increment for various servers
// NOTE: PORT_INC_APP_MANAGER may be hard-coded by client's net layer
// TODO: need to fix this to make it more flexible
PORT_INC_HTTP: 0,
PORT_INC_HTTPS: 0,
PORT_INC_WEBSOCKET: 2,
PORT_INC_SOCKETIO: 2,
PORT_INC_SOCKET: 3,
PORT_INC_APP_MANAGER: 4,
PORT_INC_LOG: 5,
PORT_INC_STREAM_IN: 6,
PORT_INC_STREAM_OUT: 7,
PORT_INC_EXPRESS: 8,
PORT_INC_EXPRESS_S: 8,
//
// entry server settings
//
PORT_ENTRY: 8080,
PORT_ENTRY_ACTUAL: 8080, // actual entry server port started
//
// G-Entry settings
//
IP_G_ENTRY: '127.0.0.1',
// port to listen for S-entry connections
PORT_G_ENTRY_PRIVATE: 31000,
// port to answer external proxy queries from clients
PORT_G_ENTRY_PUBLSR: 30000,
//
// S-entry settings
//
// NOTE: needs to specify Sproxy IP as otherwise will need to parse 'ipconfig' result
//~ IP_S_ENTRY : local_config.IP_LOBBY,
// range of ports available to S-entry
S_ENTRY_PORTRANGE: 999,
// default port of S-entry
PORT_S_ENTRY: 30001,
// # of seconds considered as TCP timeout
TIMEOUT_TCP: 30,
// # of seconds to send G-entry send stat
TIMEOUT_REPORT: 5,
//
// Settings
//
// whether to shutdown app servers if their lobby dies (default to false)
// TODO: consider to turn this in 'true' in some environments?
APPSERVER_AUTOSHUT: false,
// whether to display text stream in HTML format (for server execution log display)
REFORMAT_HTML_TEXT: false,
// default encryption type for user passwords
ENCRYPT_TYPES: ['sha512'],
// # of seconds to reload a modified script
TIMEOUT_RELOAD_SCRIPT: 1,
// millisecond limit before an incoming client event is considered timeout (combined with TIMEOUT_EXECUTE?)
TIMEOUT_EVENTHANDLE: 30000,
// # of milliseconds before an app server re-try to connect to AppManager
TIMEOUT_RECONNECT: 5000,
// # of seconds before removing an unused channel in pub/sub
TIMEOUT_UNUSED_CHANNEL_REMOVAL: 300,
// # of seconds to backup to DB (used in SR.Sync)
TIMEOUT_SYNC_PERIOD: 5,
// whether to warn against socket policy server not started at port 843
WARN_SOCKET_POLSRY_SERVER: false,
// how long a string to output when showing packets sent by server
LENGTH_OUTMSG: 500,
// list of event types excluded from showing in debug messages
HIDDEN_EVENT_TYPES: {'SR_PUBLISH': true},
// automatically connect to localhost monitor server for clustering and liveness check
CONNECT_MONITOR_ONSTART: false,
// whether to enable app/lobby mode (default to false)
ENABLE_CLUSTER_MODE: false,
//
// email server config
//
EMAIL_CONFIG: {
user: '',
password: '',
host: 'smtp.gmail.com',
ssl: true,
},
//
// web server config (TODO: move elsewhere?)
//
DEFAULT_FILES: ['index.htm', 'index.html', 'default.htm', 'default.html'],
// Wordpress host for authentication
WORDPRESS_HOST: 'https://www.imoncloud.com',
// use pm2
PM2_ENABLE: true,
// pm2 auto restart
PM2_AUTO_RESTART: false,
};
// OS Specific
console.log('process.platform: ' + process.platform);
settings.SLASH = SR.path.sep;
//if (process.platform === 'linux') {
// settings.SLASH = '/';
//} else if (process.platform === 'win32') {
// settings.SLASH = '\\';
//} else if (process.platform === 'darwin') {
// settings.SLASH = '/';
//} else {
// console.log('Unknown or incompatible OS. Currently support: linux, win32, darwin');
// process.exit(99);
//}
// merge system default (should not change easily) with local config (may be machine-specific)
// NOTE: this needs to happen before the following environment-specific defaults are applied
// otherwise settings.MODE may be incorrect
//
// Environment-specific settings
//
//console.log("settings.MODE: " + settings.MODE);
if (settings.MODE === 'dev') {
settings.SAFE_CALL = false;
settings.NOTIFY_SERVER_DOWN = false;
settings.NOTIFY_SCRIPT_RELOAD = false;
settings.LOG_LEVEL = 4;
} else if (settings.MODE === 'prod') {
settings.SAFE_CALL = true;
settings.NOTIFY_SERVER_DOWN = true;
settings.NOTIFY_SCRIPT_RELOAD = true;
settings.LOG_LEVEL = 2;
}
settings.IP_MONITOR = settings.IP_MONITOR || settings.IP_LOBBY;
settings.IP_S_ENTRY = settings.IP_S_ENTRY || settings.IP_LOBBY;