現在開発中のゲーム用のサーバーを実行しようとしています。 $git push
を実行すると、エラーApplication 'appname' failed to start (port 8080 not available)
が発生します。 (私はgit addとgit commitを実行しました)。これは私のサーバーのコードです: `OpenShiftノードサーバーを実行しています:エラーが発生しましたアプリケーション 'appname'の起動に失敗しました(ポート8080は使用できません)
//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": "[email protected]",
"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 [email protected]
remote: npm info using [email protected]
remote: npm info preinstall [email protected]
remote: npm info build /var/lib/openshift/5777be422d5271bc8b00018f/app-root/runtime/repo
remote: npm info linkStuff [email protected]
remote: npm info install [email protected]
remote: npm info postinstall [email protected]
remote: npm info prepublish [email protected]
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://[email protected]m/~/git/griffinsmod.git/
a2fb4f6..07b3114 master -> master
、私は、誰もが原因でエラーログの何かをハッキングしないことを願っていますし、申し訳ありませんこの質問が非常に長い場合は...また、これはnoobishの音、私は昨日OpenShiftとGitHubを使用し始めたごめんなさい。あなたは何か質問がある場合、またはいくつかの他の情報だけをコメントしたい!私が得ることができるどんな助けにも深く感謝します! :)
ポートを試してみてください環境変数process.env.OPENSHIFT_NODEJS_PORTを使用すると、ポートが提供されます。詳細はこちらhttps://developers.openshift.com/languages/nodejs/environment-variables.html – WinterCore
問題を解決しました。ありがとうございます。 – Grufkork