2016-07-02 4 views
0

現在開発中のゲーム用のサーバーを実行しようとしています。 $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を使用し始めたごめんなさい。あなたは何か質問がある場合、またはいくつかの他の情報だけをコメントしたい!私が得ることができるどんな助けにも深く感謝します! :)

+0

ポートを試してみてください環境変数process.env.OPENSHIFT_NODEJS_PORTを使用すると、ポートが提供されます。詳細はこちらhttps://developers.openshift.com/languages/nodejs/environment-variables.html – WinterCore

+0

問題を解決しました。ありがとうございます。 – Grufkork

答えて

0

standart Openshift Node.jsカートリッジは、環境変数を使用して待機する必要があるポートとIPを提供します。 PORTIPがあることを行うには、より一般的な方法であり、何も(DEV環境)を提供されていない場合は、それが今のように同じに耳を傾けているため

私はそのようなものを使用します。

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'; 
+0

ありがとう!これは私の問題を解決しました! :) – Grufkork

+0

'process.env.OPENSHIFT_NODEJS_PORT'の代わりに' process.env.PORT'を使って希望のポートを指定していたので、openshiftがありましたか? –

+0

いいえ、Openshiftは 'OPENSHIFT_NODEJS_PORT'を使用しています。ポートをローカルに変更する場合や、別のプラットフォームでポートを実行する場合にのみ、 'PORT'は挫折しました。しかし、オープニングシフトはそれ以来ずっと変わってしまっていて、それが同じであるかどうかは分かりません – Julian

関連する問題