-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnavajo.js
More file actions
45 lines (38 loc) · 1.04 KB
/
navajo.js
File metadata and controls
45 lines (38 loc) · 1.04 KB
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
/**
* Navajo - NodeJS HTTP Server
**/
var utils = require("./core/utils");
process.chdir(__dirname);
// load configuration
utils.loadConfig("./navajo.conf", function (err, config) {
if (err) {
console.log("ERROR");
console.log(err);
return;
}
var http = require("http"),
server = http.createServer(utils.processRequest);
// start server
try {
server.listen(config.bind.port, config.bind.host, function () {
console.log("Server started on %s:%d", config.bind.host, config.bind.port);
utils.dropPrivileges();
});
} catch (except) {
if (except.errno == 13) {
console.log("Cannot start on %s:%d - Permission denied. Are you root?", config.bind.host, config.bind.port);
} else {
console.log("Cannot start on %s:%d - %s", config.bind.host, config.bind.port, except.message);
}
process.exit(1);
}
process.on("SIGINT", function () {
console.log("Server stopping..");
utils.stopLogging();
process.exit(0);
});
process.on("SIGUSR1", function () {
console.log("Reopening logs..");
utils.reopenLogging();
});
});