-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
100 lines (81 loc) · 2.65 KB
/
server.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
/**
* Server
*
* The place where the magic starts
*
* Alchemy: a node.js framework
* Copyright 2013-2017, Jelle De Loecker
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2013-2017, Jelle De Loecker
* @link
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
require('alchemymvc');
// Change the umask so child process will leave created files & sockets
// readable by others in their group
process.umask(2);
Router.serveDependencyFile('xterm', {
file : 'lib/xterm.js',
alias : '/scripts/xterm.js',
});
Router.serveDependencyFile('xterm', {
file : 'css/xterm.css',
alias : '/stylesheets/xterm.css',
});
Router.serveDependencyFile('xterm-addon-fit', {
file : 'lib/xterm-addon-fit.js',
alias : '/scripts/xterm-addon-fit.js',
});
/**
* Overwrite an existing object without breaking references
*
* @author Jelle De Loecker <[email protected]>
* @since 0.0.1
* @version 0.0.1
*
* @param {object} target The object to overwrite
* @param {object} obj The object to replace it with
*/
alchemy.overwrite = function overwrite(target, obj) {
var key;
for (key in target) {
delete target[key];
}
for (key in obj) {
target[key] = obj[key];
}
};
// Intercept uncaught exceptions so the server won't crash
// @todo: this should be expanded and integrated into alchemy itself
process.on('uncaughtException', function(error) {
// Indicate we caught an exception
alchemy.printLog('error', ['Uncaught Exception!', String(error), error], {err: error, level: -2});
});
alchemy.start(function onAlchemyReady() {
// Do certain things when alchemy is ready
log.info('Creating site dispatcher');
// Create the dispatcher
alchemy.dispatcher = new Classes.Develry.SiteDispatcher({
// Set to false to disable fallback
fallbackAddress : alchemy.settings.fallbackAddress || null,
// localhost is the default value
redirectHost : alchemy.settings.redirectHost || 'localhost',
// Listen to this ipv6 address, too
ipv6Address : alchemy.settings.ipv6Address || '',
// The port on which the proxy will listen (probably 80)
proxyPort : alchemy.settings.proxyPort || 80,
// The https proxy port
proxyPortHttps : alchemy.settings.proxyPortHttps,
// The first port to use for child node instances
firstPort : alchemy.settings.firstPort || 4748,
// Force https?
force_https : alchemy.settings.force_https == null ? true : alchemy.settings.force_https
});
});
// Get the posix package
var posix = require('posix');
// Increase the file limit
posix.setrlimit('nofile', {soft: 60000});