Add --safe mode flag to allow starting without flows running

This commit is contained in:
Nick O'Leary
2018-09-25 11:20:50 +01:00
parent fba339f666
commit d887ab126b
6 changed files with 41 additions and 4 deletions

View File

@@ -102,6 +102,10 @@ function loadFlows() {
});
}
function load(forceStart) {
if (forceStart && settings.safeMode) {
// This is a force reload from the API - disable safeMode
delete settings.safeMode;
}
return setFlows(null,"load",false,forceStart);
}
@@ -112,6 +116,16 @@ function load(forceStart) {
*/
function setFlows(_config,type,muteLog,forceStart) {
type = type||"full";
if (settings.safeMode) {
if (type !== "load") {
// If in safeMode, the flows are stopped. We cannot do a modified nodes/flows
// type deploy as nothing is running. Can only do a "load" or "full" deploy.
// The "load" case is already handled in `load()` to distinguish between
// startup-load and api-request-load.
type = "full";
delete settings.safeMode;
}
}
var configSavePromise = null;
var config = null;
@@ -285,6 +299,13 @@ function start(type,diff,muteLog) {
events.emit("runtime-event",{id:"runtime-state",payload:{error:"missing-types", type:"warning",text:"notification.warnings.missing-types",types:activeFlowConfig.missingTypes},retain:true});
return when.resolve();
}
if (settings.safeMode) {
log.info("*****************************************************************")
log.info(log._("nodes.flows.safe-mode"));
log.info("*****************************************************************")
events.emit("runtime-event",{id:"runtime-state",payload:{error:"safe-mode", type:"warning",text:"notification.warnings.safe-mode"},retain:true});
return Promise.resolve();
}
if (!muteLog) {
if (type !== "full") {
log.info(log._("nodes.flows.starting-modified-"+type));