1
我正在使用Openshift創建我的節點紅色應用程序。 我想我的節點存儲在Openshift環境變量,它是process.env.OPENSHIFT_DATA_DIR
的用戶目錄,但是當我建立並運行我的應用我看到Openshift部署日誌此錯誤:node.js 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 [email protected]
npm info using [email protected]
npm info prestart [email protected]
npm info start [email protected]
> [email protected] start /opt/app-root/src
> node app.js
Potentially unhandled rejection [1] Error: Property 'userDir' is read-only
,這裏是我的app.js:
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();
我應該在Openshift儀表板中分別定義環境變量嗎? 謝謝。