mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Improve core test coverage
This commit is contained in:
@@ -40,12 +40,11 @@ function start() {
|
||||
var Tokens = require("./api/auth/tokens");
|
||||
var Users = require("./api/auth/users");
|
||||
var Permissions = require("./api/auth/permissions");
|
||||
|
||||
if (!settings.disableEditor) {
|
||||
Users.default().then(function(anonymousUser) {
|
||||
var webSocketKeepAliveTime = settings.webSocketKeepAliveTime || 15000;
|
||||
var path = settings.httpAdminRoot || "/";
|
||||
path = path + (path.slice(-1) == "/" ? "":"/") + "comms";
|
||||
path = (path.slice(0,1) != "/" ? "/":"") + path + (path.slice(-1) == "/" ? "":"/") + "comms";
|
||||
wsServer = new ws.Server({server:server,path:path});
|
||||
|
||||
wsServer.on('connection',function(ws) {
|
||||
@@ -127,9 +126,11 @@ function start() {
|
||||
function stop() {
|
||||
if (heartbeatTimer) {
|
||||
clearInterval(heartbeatTimer);
|
||||
heartbeatTimer = null;
|
||||
}
|
||||
if (wsServer) {
|
||||
wsServer.close();
|
||||
wsServer = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ var ConsoleLogHandler = function(settings) {
|
||||
this.metricsOn = settings.metrics||false;
|
||||
metricsEnabled = this.metricsOn;
|
||||
this.on("log",function(msg) {
|
||||
/* istanbul ignore else */
|
||||
if (this.shouldReportMessage(msg.level)) {
|
||||
if (msg.level == log.METRIC) {
|
||||
util.log("[metric] "+JSON.stringify(msg));
|
||||
|
||||
@@ -54,7 +54,7 @@ function start() {
|
||||
if (log.metric()) {
|
||||
runtimeMetricInterval = setInterval(function() {
|
||||
reportMetrics();
|
||||
}, 15000);
|
||||
}, settings.runtimeMetricInterval||15000);
|
||||
}
|
||||
console.log("\n\nWelcome to Node-RED\n===================\n");
|
||||
if (settings.version) {
|
||||
@@ -92,7 +92,7 @@ function start() {
|
||||
if (missingModules.hasOwnProperty(i)) {
|
||||
log.warn(" - "+i+": "+missingModules[i].join(", "));
|
||||
if (settings.autoInstallModules && i != "node-red") {
|
||||
installModule(i).otherwise(function(err) {
|
||||
serverAPI.installModule(i).otherwise(function(err) {
|
||||
// Error already reported. Need the otherwise handler
|
||||
// to stop the error propagating any further
|
||||
});
|
||||
@@ -216,22 +216,21 @@ function uninstallModule(module) {
|
||||
function reportMetrics() {
|
||||
var memUsage = process.memoryUsage();
|
||||
|
||||
// only need to init these once per report
|
||||
var metrics = {};
|
||||
metrics.level = log.METRIC;
|
||||
|
||||
//report it
|
||||
metrics.event = "runtime.memory.rss"
|
||||
metrics.value = memUsage.rss;
|
||||
log.log(metrics);
|
||||
|
||||
metrics.event = "runtime.memory.heapTotal"
|
||||
metrics.value = memUsage.heapTotal;
|
||||
log.log(metrics);
|
||||
|
||||
metrics.event = "runtime.memory.heapUsed"
|
||||
metrics.value = memUsage.heapUsed;
|
||||
log.log(metrics);
|
||||
log.log({
|
||||
level: log.METRIC,
|
||||
event: "runtime.memory.rss",
|
||||
value: memUsage.rss
|
||||
});
|
||||
log.log({
|
||||
level: log.METRIC,
|
||||
event: "runtime.memory.heapTotal",
|
||||
value: memUsage.heapTotal
|
||||
});
|
||||
log.log({
|
||||
level: log.METRIC,
|
||||
event: "runtime.memory.heapUsed",
|
||||
value: memUsage.heapUsed
|
||||
});
|
||||
}
|
||||
|
||||
function stop() {
|
||||
@@ -243,7 +242,7 @@ function stop() {
|
||||
comms.stop();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
var serverAPI = module.exports = {
|
||||
init: init,
|
||||
start: start,
|
||||
stop: stop,
|
||||
|
||||
Reference in New Issue
Block a user