2016-03-31 9 views
0

OpenShiftでホストしようとしているhapiを使用しているnode.jsアプリケーションがあります。私はサーバーにアプリをアップロードしました。明らかにpackage.jsonファイルを読み込み、app.jsファイルを実行します。hapiを使用したnode.jsアプリのOpenshift 503

しかし、私がサイトにアクセスすると、503エラーが表示されます。

Package.jsonファイル:

{ 
"name": "app", 
    "version": "1.0.0", 
    "description": "", 
    "main": "server.js", 
    "dependencies": { 
    "after": "^0.8.1", 
    "bcryptjs": "2.3.0", 
    "bootstrap": "^3.3.6", 
    "forever": "^0.15.1", 
    "gulp": "^3.9.0", 
    "gulp-nodemon": "^2.0.4", 
    "handlebars": "4.0.5", 
    "hapi": "^8.8.1", 
    "hapi-auth-cookie": "^3.1.0", 
    "knex": "^0.9.0", 
    "mysql": "^2.9.0", 
    "nodemon": "^1.8.0", 
    "request": "^2.69.0", 
    "tree-model": "^1.0.4" 
    }, 
    "devDependencies": {}, 
    "scripts": { 
    "start": "node server.js" 
    } 
    "author": "", 
    "license": "ISC" 
} 

*注:リポジトリ情報は、package.jsonペーストから削除されました。

app.jsファイル:

var Hapi = require('hapi'); 
var fs = require('fs'); 

fs.readFile('./bin/dbcfg.txt', 'utf8', function(err, data){ 
    if (err){ 
     console.log(err); 
    } 
    else{ 
     data = JSON.parse(data); 
     process.env.client = data.client; 
     process.env.host = data.connection.host; 
     process.env.user = data.connection.user; 
     process.env.password = data.connection.password; 
     process.env.database = data.connection.database; 
     fs.readFile('./bin/strategycfg.txt', 'utf8', function(err, data){ 
     if(err){ 
      console.log(err); 
     } 
     else{ 
      var strategyCFG = JSON.parse(data); 
      server = new Hapi.Server(); 
      server.connection({ port : 3000, address: process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1' }); 
      server.register(require('hapi-auth-cookie'), function(err){ 
       if(err){ 
        console.log(err); 
       } 
       server.auth.strategy('default', 'cookie',strategyCFG); 
       server.auth.default('default'); 
       const defaultContext = { 
        title: 'App' 
       }; 
       server.views({ 
        engines: { 
         html: require('handlebars') 
        }, 
        context: defaultContext, 
        path: ['public/html', 'private/html'], 
        layoutPath: 'public/templates', 
        layout: 'default' 
        //, 
        //helpersPath: 'views/helpers', 
        //partialsPath: 'views/partials' 
       }); 
      }); 

      server.route(require('./lib/Routes')); 

      server.start(function() { 
       console.log('Running on 3000'); 
      }); 
     } 
    }); 
} 

})。

私はRHCテール-aのAPPNAMEを実行し、これを受けた:

==> app-root/logs/haproxy.log <== 
[WARNING] 090/180806 (276379) : config : log format ignored for proxy 'stats' since it has no log address. 
[WARNING] 090/180806 (276379) : config : log format ignored for proxy 'express' since it has no log address. 
[WARNING] 090/180806 (276379) : Server express/local-gear is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue. 
[ALERT] 090/180806 (276379) : proxy 'express' has no server available! 
[WARNING] 090/180919 (276379) : Server express/local-gear is DOWN for maintenance. 
[WARNING] 090/180919 (279772) : config : log format ignored for proxy 'stats' since it has no log address. 
[WARNING] 090/180919 (279772) : config : log format ignored for proxy 'express' since it has no log address. 
[WARNING] 090/180919 (279772) : Server express/local-gear is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue. 
[ALERT] 090/180919 (279772) : proxy 'express' has no server available! 
[WARNING] 090/180923 (279772) : Server express/local-gear is DOWN for maintenance. 

==> app-root/logs/haproxy_ctld.log <== 
I, [2016-03-30T22:04:51.536078 #521102] INFO -- : Starting haproxy_ctld 
I, [2016-03-30T22:11:34.136340 #49489] INFO -- : Starting haproxy_ctld 
I, [2016-03-30T22:25:04.802167 #98826] INFO -- : Starting haproxy_ctld 
I, [2016-03-30T22:29:56.842182 #117627] INFO -- : Starting haproxy_ctld 
I, [2016-03-30T22:32:36.247075 #130978] INFO -- : Starting haproxy_ctld 
I, [2016-03-30T22:39:12.046805 #156995] INFO -- : Starting haproxy_ctld 
I, [2016-03-30T23:01:39.741187 #237078] INFO -- : Starting haproxy_ctld 
I, [2016-03-30T23:07:00.948129 #255019] INFO -- : Starting haproxy_ctld 
I, [2016-03-31T18:08:07.635718 #276393] INFO -- : Starting haproxy_ctld 
I, [2016-03-31T18:09:20.552771 #279795] INFO -- : Starting haproxy_ctld 

==> app-root/logs/npm-debug.log <== 
5 error package.json npm can't find a package.json file in your current directory. 
6 error System Linux 2.6.32-573.12.1.el6.x86_64 
7 error command "node" "/opt/rh/nodejs010/root/usr/bin/npm" "install" 
8 error cwd /var/lib/openshift/xxxxxxxx/app-root/logs 
9 error node -v v0.10.35 
10 error npm -v 1.4.28 
11 error path /var/lib/openshift/xxxxxxxx/app-root/logs/package.json 
12 error code ENOPACKAGEJSON 
13 error errno 34 
14 verbose exit [ 34, true ] 

==> app-root/logs/nodejs.log <== 
DEBUG: Sending SIGTERM to child... 
DEBUG: Running node-supervisor with 
DEBUG: program 'server.js' 
DEBUG: --watch '/var/lib/openshift/xxxxxxx/app-root/data/.nodewatch' 
DEBUG: --ignore 'undefined' 
DEBUG: --extensions 'node|js|coffee' 
DEBUG: --exec 'node' 
DEBUG: Starting child process with 'node server.js' 
DEBUG: Watching directory '/var/lib/openshift/xxxxxxx/app-root/data/.nodewatch' for changes. 
Running on 3000 

「3000上で実行」私はアプリが実行されていると思わせるが、OpenShiftサイトは私に503

どれを与えますすべての助けが大いに評価されるでしょう。みんな、ありがとう!

答えて

0

あなたは、このようなホストアドレスの代わりに使用しようとすることができます:

server.connection({ host:'0.0.0.0', port: 3000}); 

はまた、私はオープンシフトはまた、ポートの環境変数を公開すると思います。