2
0
mirror of https://github.com/Ride-The-Lightning/RTL synced 2024-11-19 15:25:29 +00:00
RTL/rtl.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

#!/usr/bin/env node
const app = require("./routes/app");
const common = require("./routes/common");
2018-09-15 01:31:01 +00:00
const http = require("http");
var connect = require("./routes/connect").setServerConfiguration(); //Do NOT Remove
2018-09-15 01:31:01 +00:00
const onError = error => {
if (error.syscall !== "listen") {
throw error;
}
switch (error.code) {
case "EACCES":
console.error("http://" + (common.host ? common.host : 'localhost') + ":" + common.port + " requires elevated privileges");
2018-09-15 01:31:01 +00:00
process.exit(1);
case "EADDRINUSE":
console.error("http://" + (common.host ? common.host : 'localhost') + ":" + common.port + " is already in use");
2018-09-15 01:31:01 +00:00
process.exit(1);
2019-01-01 16:26:51 +00:00
case "ECONNREFUSED":
console.error("Server is down/locked");
process.exit(1);
case "EBADCSRFTOKEN":
console.error("Form tempered");
process.exit(1);
2018-09-15 01:31:01 +00:00
default:
2019-01-01 16:26:51 +00:00
console.error("DEFUALT ERROR");
console.error(error.code);
2018-09-15 01:31:01 +00:00
throw error;
}
};
const onListening = () => {
console.log('Server is up and running, please open the UI at http://' + (common.host ? common.host : 'localhost') + ':' + common.port);
2018-09-15 01:31:01 +00:00
};
const server = http.createServer(app);
2018-09-15 01:31:01 +00:00
server.on("error", onError);
server.on("listening", onListening);
if (common.host) {
server.listen(common.port, common.host);
} else {
server.listen(common.port);
}