运行OpenShift节点服务器:获取错误Application 'appname'启动失败(8080端
Running an OpenShift node server: Getting error Application 'appname' failed to start (port 8080 not available)
我正在尝试为我正在开发的游戏运行服务器。当我运行$git push
时,我得到了错误Application 'appname' failed to start (port 8080 not available)
。(我之前运行过git add和git commit)。这是我的服务器代码:'
//Lets require/import the HTTP module
var http = require('http');
//var fs = require("fs");
//var index = fs.readFileSync('test.txt');
//Lets define a port we want to listen to
const PORT=8081;
//We need a function which handles requests and send response
function handleRequest(request, response){
response.end("hi");
}
//Create a server
var server = http.createServer(handleRequest);
//Lets start our server
server.listen(PORT, "127.0.0.1",function(){
//Callback triggered when server is successfully listening.
console.log("Server listening on: http://localhost:%s", PORT);
});
根据我所做的研究,如果你的代码中有错误,你会得到端口不可用错误,但我已经测试了在我的计算机上本地运行应用程序,它运行得很好(我能够连接,我看到消息"hi")。我注释掉文件系统(fs)的原因是因为我想测试问题是否是因为OpenShift应用程序没有安装fs(它不是)。我也尝试运行一个完全空的服务器,但我仍然得到同样的错误。因此,我认为问题不在于丢失了什么包裹。我已经检查了8080端口上是否已经有东西在运行,但是我没有看到任何东西。
package.json:
{
"name": "OpenShift-Sample-App",
"version": "1.0.0",
"description": "OpenShift Sample Application",
"keywords": [
"OpenShift",
"Node.js",
"application",
"openshift"
],
"author": {
"name": "OpenShift",
"email": "ramr@example.org",
"url": "http://www.openshift.com/"
},
"homepage": "http://www.openshift.com/",
"repository": {
"type": "git",
"url": "https://github.com/openshift/origin-server"
},
"engines": {
"node": ">= 0.6.0",
"npm": ">= 1.0.0"
},
"dependencies": {
"express": "~3.4.4"
},
"scripts": {
"start": "node htmlServer.js"
},
"devDependencies": {},
"bundleDependencies": [],
"private": true,
"main": "htmlServer.js"
}
错误日志:warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 332 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Stopping NodeJS cartridge
remote: Sat Jul 02 2016 14:17:48 GMT-0400 (EDT): Stopping application 'griffinsmod' ...
remote: Sat Jul 02 2016 14:17:49 GMT-0400 (EDT): Stopped Node application 'griffinsmod'
remote: Saving away previously installed Node modules
remote: Building git ref 'master', commit 07b3114
remote: Building NodeJS cartridge
remote: npm info it worked if it ends with ok
remote: npm info using npm@1.4.28
remote: npm info using node@v0.10.35
remote: npm info preinstall OpenShift-Sample-App@1.0.0
remote: npm info build /var/lib/openshift/5777be422d5271bc8b00018f/app-root/runtime/repo
remote: npm info linkStuff OpenShift-Sample-App@1.0.0
remote: npm info install OpenShift-Sample-App@1.0.0
remote: npm info postinstall OpenShift-Sample-App@1.0.0
remote: npm info prepublish OpenShift-Sample-App@1.0.0
remote: npm info ok
remote: Preparing build for deployment
remote: Deployment id is 6f6c7880
remote: Activating deployment
remote: Starting NodeJS cartridge
remote: Sat Jul 02 2016 14:18:15 GMT-0400 (EDT): Starting application 'griffinsmod' ...
remote: Waiting for application port (8080) become available ...
remote: Application 'griffinsmod' failed to start (port 8080 not available)
remote: -------------------------
remote: Git Post-Receive Result: failure
remote: Activation status: failure
remote: Activation failed for the following gears:
remote: 5777be422d5271bc8b00018f (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/5777be422d5271bc8b00018f/nodejs
remote: #<IO:0x000000011ac290>
remote: #<IO:0x000000011ac218>
remote: )
remote: Deployment completed with status: failure
remote: postreceive failed
To ssh://5777be422d5271bc8b00018f@griffinsmod-snowballdynamics.rhcloud.com/~/git/griffinsmod.git/
a2fb4f6..07b3114 master -> master
我真的不关心审查任何信息,我希望没有人因为错误日志而窃取任何东西,如果这个问题很长,很抱歉…也很抱歉,如果这听起来很无聊,我昨天开始使用OpenShift和GitHub。如果你有任何问题或想要一些其他信息,请评论!我将非常感谢任何帮助我可以得到!:)
标准的Openshift Node.js磁带提供了您应该使用环境变量侦听的端口和IP。
我会使用这样的东西,因为PORT
和IP
是更常见的方法,如果没有提供(开发环境),它会像现在一样听:
const PORT = process.env.OPENSHIFT_NODEJS_PORT ||process.env.PORT || 8080;
const IP = process.env.OPENSHIFT_NODEJS_IP || process.env.IP || '0.0.0.0';
相关文章:
- 我的jQuery插件参数没有正确启动,遇到了问题
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- 从控制器返回后Ajax启动事件激发
- Meteor上的启动页面
- 如何防止网页加载后自动启动功能
- 如何从JavaScriptInterface启动Navigation Drawer
- window.on.scroll事件未启动
- 单击按钮后启动javascript提示
- 在javaservlet doPost方法中启动线程时,无法返回异常消息
- spine.js在启动时填充模型实例
- 如何在所有ng点击事件AngularJS上启动一个方法
- jQuery悬停在没有鼠标悬停的情况下启动
- SignalR客户端启动连接时如何设置用户
- Meteor:在启动时将html注入客户端文件
- Angular UI启动日期选择器问题
- 如何用低音量自动启动Youtube视频(iframe)
- jQuery mouseup在拖离链接后未启动
- 在同一选项卡中启动下载,而无需在Javascript中打开新选项卡或窗口
- 为什么我的控制器没有启动函数.js脚本
- 运行OpenShift节点服务器:获取错误Application 'appname'启动失败(8080端