-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
executable file
·35 lines (31 loc) · 1001 Bytes
/
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
/*global console*/
var yetify = require('yetify'),
config = require('getconfig'),
fs = require('fs'),
sockets = require('./sockets'),
port = parseInt(process.env.PORT || config.server.port, 10),
server_handler = function (req, res) {
res.writeHead(404);
res.end();
},
server = null;
// Create an http(s) server instance to that socket.io can listen to
if (config.server.secure) {
server = require('https').Server({
key: fs.readFileSync(config.server.key),
cert: fs.readFileSync(config.server.cert),
passphrase: config.server.password
}, server_handler);
} else {
server = require('http').Server(server_handler);
}
server.listen(port);
sockets(server, config);
if (config.uid) process.setuid(config.uid);
var httpUrl;
if (config.server.secure) {
httpUrl = "https://localhost:" + port;
} else {
httpUrl = "http://localhost:" + port;
}
console.log(yetify.logo() + ' -- signal master is running at: ' + httpUrl);