forked from DemocracyOS/hub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·50 lines (39 loc) · 1.07 KB
/
index.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
/**
* Module dependencies.
*/
var config = require('lib/config');
var http = require('http');
var https = require('https');
var express = require('express');
var app = module.exports = require('lib/boot');
var fs = require('fs');
var debug = require('debug')('hub');
var secure = 'https' == config('protocol');
/**
* Configure standard server
*/
var server = http.createServer(app);
var port = config('privatePort');
/**
* Configure secure server (SSL) if necessary
*/
var secureServer;
var securePort;
if (secure) {
var ssl = config('ssl');
var privateKey = fs.readFileSync(ssl.serverKey, 'utf-8');
var certificate = fs.readFileSync(ssl.serverCert, 'utf-8');
secureServer = https.createServer({ key: privateKey, cert: certificate }, app);
securePort = ssl.port;
}
/**
* Launch servers
*/
server.listen(app.get('privatePort'), function() {
debug('Application started on port %d', app.get('privatePort'));
});
if (secureServer && securePort) {
secureServer.listen(securePort, function() {
debug('Secure application started on port %d', securePort);
});
}