2013-10-11 20:48:01 +00:00
|
|
|
var Server = require("./lib/server");
|
|
|
|
var Config = require("./lib/config");
|
2013-10-11 21:31:40 +00:00
|
|
|
var Logger = require("./lib/logger");
|
2015-09-21 05:06:53 +00:00
|
|
|
require("source-map-support").install();
|
2013-10-11 20:48:01 +00:00
|
|
|
|
2014-01-22 23:11:26 +00:00
|
|
|
Config.load("config.yaml");
|
|
|
|
var sv = Server.init();
|
|
|
|
if (!Config.get("debug")) {
|
|
|
|
process.on("uncaughtException", function (err) {
|
|
|
|
Logger.errlog.log("[SEVERE] Uncaught Exception: " + err);
|
|
|
|
Logger.errlog.log(err.stack);
|
|
|
|
});
|
2013-10-11 20:48:01 +00:00
|
|
|
|
2014-01-22 23:11:26 +00:00
|
|
|
process.on("SIGINT", function () {
|
|
|
|
sv.shutdown();
|
|
|
|
});
|
|
|
|
}
|
2014-02-26 20:28:24 +00:00
|
|
|
|
|
|
|
var stdinbuf = "";
|
|
|
|
process.stdin.on("data", function (data) {
|
|
|
|
stdinbuf += data;
|
|
|
|
if (stdinbuf.indexOf("\n") !== -1) {
|
|
|
|
var line = stdinbuf.substring(0, stdinbuf.indexOf("\n"));
|
|
|
|
stdinbuf = stdinbuf.substring(stdinbuf.indexOf("\n") + 1);
|
|
|
|
handleLine(line);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function handleLine(line) {
|
|
|
|
if (line === "/reload") {
|
|
|
|
Logger.syslog.log("Reloading config");
|
|
|
|
Config.load("config.yaml");
|
2014-04-11 02:54:46 +00:00
|
|
|
} else if (line === "/gc") {
|
|
|
|
if (global && global.gc) {
|
|
|
|
Logger.syslog.log("Running GC");
|
|
|
|
global.gc();
|
|
|
|
} else {
|
|
|
|
Logger.syslog.log("Failed to invoke GC: node started without --expose-gc");
|
|
|
|
}
|
2014-06-24 05:15:57 +00:00
|
|
|
} else if (line === "/delete_old_tables") {
|
|
|
|
require("./lib/database/update").deleteOldChannelTables(function (err) {
|
|
|
|
if (!err) {
|
|
|
|
Logger.syslog.log("Deleted old channel tables");
|
|
|
|
}
|
|
|
|
});
|
2014-02-26 20:28:24 +00:00
|
|
|
}
|
|
|
|
}
|