我正在使用Openshift来创建我的节点红应用程序。
我想将我的节点存储在Openshift环境变量的用户目录中 Environment:
DEV_MODE=false
NODE_ENV=production
DEBUG_PORT=5858
Launching via npm...
npm info it worked if it ends with ok
npm info using npm@2.15.1
npm info using node@v4.6.2
npm info prestart node-red-app@
npm info start node-red-app@
> node-red-app@ start /opt/app-root/src
> node app.js
Potentially unhandled rejection [1] Error: Property 'userDir' is read-only
但是当我构建并运行我的应用程序时,我看到来自Openshift部署日志的错误:
var http = require('http');
var express = require("express");
var RED = require("node-red");
// Create an Express app
var app = express();
// Add a simple route for static content served from 'public'
app.use("/",express.static("public"));
// Create a server
var server = http.createServer(app);
// Create the settings object - see default settings.js file for other options
var settings = {
nodesDir: process.env.OPENSHIFT_DATA_DIR,
httpAdminRoot:"/",
httpNodeRoot: "/api",
userDir: process.env.OPENSHIFT_DATA_DIR,
uiPort: 8080,
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);
server.listen(8080);
// Start the runtime
RED.start();
这是我的app.js:
{{1}}
我应该在Openshift仪表板中单独定义环境变量吗? 感谢。
答案 0 :(得分:1)
我通过在部署仪表板中定义此环境变量来解决它:
app-root/data
为str_val
。
我的node.js代码没有问题。