Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
verbose: false,
flowFile: path.join(basedir, 'flows_Dispatcher.json'),
mqtt_dynamic:
{
broker: config.broker.host,
broker_port: (config.broker.port ? config.broker.port : 1883),
broker_username: config.broker.username,
broker_password: config.broker.password,
clientid: config.clientid,
clientconfig: objUtil.extend(clientconfig, { "status": "online" }),
clientconfig_offline: objUtil.extend(clientconfig, { "status": "offline" })
}
};
// Initialise the runtime with a server and settings
RED.init(server, settings);
// Serve the editor UI from /red
app.use(settings.httpAdminRoot, RED.httpAdmin);
// Serve the http nodes UI from /api
app.use(settings.httpNodeRoot, RED.httpNode);
server.listen(8000);
// Start the runtime
RED.start();
console.log("=================================================");
console.log("Flows Dir : " + path.resolve(settings.userDir));
console.log("Node-Red Url : http://localhost:8000/red/");
console.log("=================================================");
let init = (() => {
if (headless) {
RED.init(settings)
}else{
RED.init(server, settings)
//app.use(settings.httpAdminRoot,RED.httpAdmin);
app.use(settings.httpNodeRoot,RED.httpNode);
}
return new Promise((resolve, reject) => {
let deployed;
RED.events.on("runtime-event", deployed = function(data){
if (data.id === "runtime-deploy") {
RED.events.removeListener("runtime-event", deployed);
// console.log('flow deployed');
resolve();
}
})
RED.start();
});
// Create the http(s) server
if (use_https) {
var privateKey = fs.readFileSync("server.key", "utf8");
var certificate = fs.readFileSync("server.crt", "utf8");
var credentials = {
key: privateKey,
cert: certificate
};
}
var httpServer = use_https
? http.createServer(credentials, app)
: http.createServer(app);
// Initialise the runtime with a server and settings
// @see http://nodered.org/docs/configuration.html
RED.init(httpServer, nrSettings);
// Serve the editor UI from /admin
app.use(nrSettings.httpAdminRoot, RED.httpAdmin);
// Serve the http nodes from /
app.use(nrSettings.httpNodeRoot, RED.httpNode);
httpServer.listen(http_port, listening_address, function() {
console.info(
"Express 4 https server listening on http%s://%s:%d%s, serving node-red",
use_https ? "s" : "",
httpServer.address().address.replace("0.0.0.0", "localhost"),
httpServer.address().port,
nrSettings.httpAdminRoot
);
});
console.log('VCAP_SERVICES: %s', process.env.VCAP_SERVICES);
// Also parse Cloudant settings.
var couchService = env['cloudantNoSQLDB'][0]['credentials'];
}
if (!couchService) {
console.log("Failed to find Cloudant service");
if (process.env.NODE_RED_STORAGE_NAME) {
console.log(" - using NODE_RED_STORAGE_NAME environment variable: "+process.env.NODE_RED_STORAGE_NAME);
}
throw new Error("No cloudant service found");
}
settings.couchUrl = couchService.url;
// Initialise the runtime with a server and settings
RED.init( httpServer, settings );
// Serve the editor UI from /red
app.use( settings.httpAdminRoot, RED.httpAdmin );
// Serve the http nodes UI from /api
app.use( settings.httpNodeRoot, RED.httpNode );
httpServer.listen( port, function(){
console.log('App listening on port: ', port);
});
// Start the runtime
RED.start();
// See node-red configuration documentation for options.
var settings = {
httpRoot:'/red',
httpNodeRoot: '/api',
adminAuth: require('./user-authentication'),
editorTheme: {
projects: {
enabled: true
}
},
functionGlobalContext: { } // enables global context
};
// Initialise the runtime with Meteor http server and settings
RED.init(WebApp.httpServer, settings);
// Serve the editor UI from /red
app.use(settings.httpRoot, RED.httpAdmin);
// Serve the http nodes UI from /api
app.use(settings.httpNodeRoot, RED.httpNode);
WebApp.connectHandlers.use('/', app);
RED.start();
if (options && options.settings) {
settings = options.settings;
} else {
settings = {
httpAdminRoot : '/red',
httpNodeRoot : '/redapi',
userDir : 'nodered/',
nodesDir : '../nodes',
flowFile : 'node-red-flows.json',
functionGlobalContext : {}
// enables global context
};
}
// Initialise the runtime with a server and settings
RED.init(server, settings);
// Serve the editor UI from /red
app.use(settings.httpAdminRoot, RED.httpAdmin);
// Serve the http nodes UI from /api
app.use(settings.httpNodeRoot, RED.httpNode);
var adminApp = RED.httpAdmin;
var redNodes = RED.nodes;
if (!options.settings.server) {
var port = options ? options.port || 3001 : 3001;
server.listen(port);
RED.start().then(function () {
return callback();
});
}
nodesDir: __dirname + "/reduser/nodes/",
functionGlobalContext: {
node : node,
nodeAPI : nodeAPI,
ledger : ledger,
rtp_ext_id : extDefNodeID,
pipelinesID : pipelines.id,
genericID : device.id,
updated : false
}, // enables global context
paletteCategories: ['subflows', 'funnel', 'valve', 'fitting', 'spout', 'testing', 'input', 'output', 'function', 'social', 'mobile', 'storage', 'analysis', 'advanced'],
logging: { console : { level : "error", audit : false } }
};
// Initialise the runtime with a server and settings
RED.init(server,settings);
// Serve the editor UI from /red
app.use(settings.httpAdminRoot, RED.httpAdmin);
// Serve the http nodes UI from /api
app.use(settings.httpNodeRoot, RED.httpNode);
server.listen(+properties.redPort);
// Start the runtime - function can be used to do work after types are loaded
RED.start().then(function () {
RED.log.info("STARTED!");
});
// Run flow configurations once flows are loaded
var EE = require('events').EventEmitter;
async function createServer() {
const port = (await Config.readConfig()).manufacturer.port;
const app = express();
const server = http.createServer(app);
const nodeRedSettings = {
flowFile: path.join(__dirname, '../../config/node-red-flow.json'),
httpAdminRoot: '/node-red',
httpNodeRoot: '/node-red/api',
};
RED.init(server, nodeRedSettings);
app.use(nodeRedSettings.httpAdminRoot, RED.httpAdmin);
app.use(nodeRedSettings.httpNodeRoot, RED.httpNode);
await setup(app, SERVER_CONFIG);
server.listen(port, () => {
console.log(`Server started on port ${port}`);
});
RED.start();
}
const source = path.join(app.getAppPath(), "node_modules", "grpc", "src", "node", "extension_binary");
const target = path.join(m[1], 'src', 'node');
console.log(source)
console.log(target)
copyFolderRecursiveSync(source, target);
}
}
}
}
}
}
};
let http_app = express();
let server = http.createServer(http_app);
RED.init(server, settings);
http_app.use(settings.httpAdminRoot, RED.httpAdmin);
http_app.use(settings.httpNodeRoot, RED.httpNode);
RED.start().then(function () {
server.listen(listenPort, "127.0.0.1", ()=>{
status = "online";
resolve();
});
});
} else {
status = "external";
reject();
}
});
private setupRED() {
log.debug(">>> settings", this.settings);
RED.init(this.server, this.settings);
this.setupDebugOut()
this.app.use(this.settings.httpAdminRoot, RED.httpAdmin);
if (this.settings.httpNodeAuth) {
this.app.use(
this.settings.httpNodeRoot,
this.basicAuthMiddleware(
this.settings.httpNodeAuth.user,
this.settings.httpNodeAuth.pass
)
);
}
this.app.use(this.settings.httpNodeRoot, RED.httpNode);
}