繁体   English   中英

Openshift中的Node Js Application主机

[英]Node Js Application host in openshift

OpenShift是Red Hat的平台即服务(PaaS),允许开发人员在云环境中快速开发,托管和扩展应用程序。 使用OpenShift,您可以选择产品,包括在线,内部和开源项目选项。 我正在尝试将我的应用程序托管在openshift中。 当我向请求添加git存储库时,它给出了一个错误。

HAProxy instance is started
HAProxy instance is started
The initial build for the application failed: Shell command '/sbin/runuser -s /bin/sh 56540dff7628e1120c000006 -c "exec /usr/bin/runcon 'unconfined_u:system_r:openshift_t:s0:c5,c81' /bin/sh -c \"gear postreceive --init >> /tmp/initial-build.log 2>&1\""' returned an error. rc=255

.Last 10 kB of build output:
Stopping NodeJS cartridge
Repairing links for 1 deployments
Saving away previously installed Node modules
Building git ref 'master', commit a601415
Building NodeJS cartridge
npm info it worked if it ends with ok
npm info using npm@1.4.28
npm info using node@v0.10.35
npm info preinstall JsFBApps@0.0.0
npm info build /var/lib/openshift/56540dff7628e1120c000006/app-root/runtime/repo
npm info linkStuff JsFBApps@0.0.0
npm info install JsFBApps@0.0.0
npm info postinstall JsFBApps@0.0.0
npm info prepublish JsFBApps@0.0.0
npm info ok 
Preparing build for deployment
Deployment id is 023a0c45
Activating deployment
HAProxy already running
Starting NodeJS cartridge
Tue Nov 24 2015 02:15:34 GMT-0500 (EST): Starting application 'jsfbapps' ...
Waiting for application port (8080) become available ...
Application 'jsfbapps' failed to start (port 8080 not available)
-------------------------
Git Post-Receive Result: failure
Activation status: failure
Activation failed for the following gears:
56540dff7628e1120c000006 (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/56540dff7628e1120c000006/nodejs
#<IO:0x00000000ebd2a0>
#<IO:0x00000000ebd228>
)
Deployment completed with status: failure
postreceive failed

您能告诉我您的代码如何设置监听的IP和端口。

如果您使用的是Express框架,请使用以下代码:

var ipaddress = process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1";
var port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
app.listen(port, ipaddress, function() {
    // Do your stuff
});

您需要使用由OpenShift定义并在其环境变量中指定的IP和端口。

process.env.OPENSHIFT_NODEJS_IP

process.env.OPENSHIFT_NODEJS_PORT

https://developers.openshift.com/zh-CN/node-js-environment-variables.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM