【发布时间】:2017-12-07 19:36:28
【问题描述】:
刚刚使用 node 创建了一个非常简单的 hello world 应用程序:
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!');
});
var server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080
var server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1'
app.listen(server_port, server_ip_address, function () {
console.log( "Listening on " + server_ip_address + ", port " + server_port )
});
它在我的本地机器上按预期工作,
把它放在 github 上并将其部署在 openshift 上,创建 pod 并且服务器运行良好: 但是当我浏览 the route 时,我可以在 Application>>routes 菜单中找到它:
Application is not available
The application is currently not serving requests at this endpoint. It may not have been started or is still starting.
I guess I'm using the latest version of openshift since just created an account.
我期待它向我展示 Hello 世界!
更新1:
这是我的 package.json:
{
"name": "npmtest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.16.2"
}
}
【问题讨论】:
标签: node.js deployment openshift