最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

node red openshift用户目录

IT培训 admin 4浏览 0评论

node red openshift用户目录

我正在使用Openshift来创建我的节点红应用程序。我想将我的节点存储在Openshift环境变量的用户目录中,这是process.env.OPENSHIFT_DATA_DIR但是当我构建并运行我的应用程序时,我看到来自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 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

这是我的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仪表板中单独定义环境变量吗?谢谢。

回答如下:

我通过在部署仪表板中定义此环境变量解决了这个问题:OPENSHIFT_DATA_DIRapp-root/data。我的node.js代码没有问题。

node red openshift用户目录

我正在使用Openshift来创建我的节点红应用程序。我想将我的节点存储在Openshift环境变量的用户目录中,这是process.env.OPENSHIFT_DATA_DIR但是当我构建并运行我的应用程序时,我看到来自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 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

这是我的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仪表板中单独定义环境变量吗?谢谢。

回答如下:

我通过在部署仪表板中定义此环境变量解决了这个问题:OPENSHIFT_DATA_DIRapp-root/data。我的node.js代码没有问题。

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论