forked from svrjs/svrjs
Disable console.log for non-TTY stdout
This commit is contained in:
parent
00d01e7cf5
commit
881502d897
1 changed files with 24 additions and 0 deletions
24
src/index.js
24
src/index.js
|
@ -8,6 +8,13 @@ const version = svrjsInfo.version;
|
|||
//const parseURL = require("./utils/urlParser.js");
|
||||
//const fixNodeMojibakeURL = require("./utils/urlMojibakeFixer.js");
|
||||
|
||||
let inspector = undefined;
|
||||
try {
|
||||
inspector = require("inspector");
|
||||
} catch (err) {
|
||||
// Don't use inspector
|
||||
}
|
||||
|
||||
// Create log, mods and temp directories, if they don't exist.
|
||||
if (!fs.existsSync(__dirname + "/log")) fs.mkdirSync(__dirname + "/log");
|
||||
if (!fs.existsSync(__dirname + "/mods")) fs.mkdirSync(__dirname + "/mods");
|
||||
|
@ -15,6 +22,23 @@ if (!fs.existsSync(__dirname + "/temp")) fs.mkdirSync(__dirname + "/temp");
|
|||
|
||||
const serverconsoleConstructor = require("./utils/serverconsole.js");
|
||||
|
||||
let inspectorURL = undefined;
|
||||
try {
|
||||
if (inspector) {
|
||||
inspectorURL = inspector.url();
|
||||
}
|
||||
} catch (err) {
|
||||
// Failed to get inspector URL
|
||||
}
|
||||
|
||||
if (!process.stdout.isTTY && !inspectorURL) {
|
||||
// When stdout is not a terminal and not attached to an Node.JS inspector, disable it to improve performance of SVR.JS
|
||||
console.log = function () {};
|
||||
process.stdout.write = function () {};
|
||||
process.stdout._write = function () {};
|
||||
process.stdout._writev = function () {};
|
||||
}
|
||||
|
||||
let configJSON = {};
|
||||
|
||||
// TODO: configuration from config.json
|
||||
|
|
Reference in a new issue