-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (35 loc) · 878 Bytes
/
Copy pathindex.js
File metadata and controls
45 lines (35 loc) · 878 Bytes
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
'use strict';
const
express = require("express");
const
log = require("./log"),
config = require("./config");
global.__rootname = __dirname;
let app = express();
global.app = app;
require("./ipc");
app.set('view engine', 'pug');
app.locals.config = config;
app.locals.path = require("path");
app.locals.baseurl = `${config.scheme}://${config.domain}`;
app.locals.ansicolor = require("ansicolor");
app.use(require("./init/"));
app.use((error, req, res, next) => {
res.status(500).render('error/500', {error});
if(config.debug) {
log.error(error);
}
})
Object.assign(app.locals, global.locals);
let port = process.env.PORT || 8080;
process.nextTick(function listen() {
try {
app.listen(port);
}
catch(e) {
log.error("Failed to listen to port", port, "retrying...");
timers.setTimeout(listen, 100);
return;
}
log.info("Listening on port", port);
});