문제

I have working SailsJS app that I want to deploy to Openshift, but as usual it doesn't go smoothly. Here's what I did so far:

rhc app create myApp nodejs-0.10
rhc cartridge add mongodb-2.4

After these two, I can see that app is created and when I visit given URL, I got Welcome page.

I installed RockMongo, and I see that I can visit my mongodb as well.

Since I already have code, I proceed with following:

git remote add openshift -f <openshift-git-repo-url>
git merge openshift/master -s recursive -X ours
git push openshift HEAD

After I merge my existing code with remote openshift (like in commands above), things start to go wrong.

When I visit url to application, I receive 503 Service temporarily unavailable. If I visit RockMongo and try to login with given credentials, I receive

Unable to connect MongoDB, please check your configurations. 
MongoDB said:Failed to connect to: 127.10.37.130:27017: Transport endpoint is not connected.

Also, in Applications Panel, status of my application is building (and stays like that for hours). After pushing code to openshift, application stopped, and after rebuilding it (automatically) I receive some errors, where the last one is

remote: An error occurred executing 'gear postreceive' (exit code: 34)
remote: Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/538f1c205004461655000227/nodejs

Does anyone has idea what's going on?

Maybe I didn't set up ports, application url, db url properly? But then again, why RockMongo stopped working?

UPDATE

Here's my mongo config:

 mongo: {
   module: 'sails-mongo',
   user: 'admin',
   password: '********',
   url: process.env.OPENSHIFT_MONGODB_DB_URL + 'surge'
 }

Do I need to set up server_port = process.env.OPENSHIFT_NODEJS_PORT and server_ip_address = process.env.OPENSHIFT_NODEJS_IP as well? I have some server.js file in root of my application, and I see that these variables are used here.

Here's what I get if I run env | grep NODEJS

OPENSHIFT_NODEJS_PATH_ELEMENT=/var/lib/openshift/538f1c205004461655000227//.node_modules/.bin:/opt/rh/nodejs010/root/usr/bin
OPENSHIFT_NODEJS_PORT=8080
OPENSHIFT_NODEJS_LD_LIBRARY_PATH_ELEMENT=/opt/rh/nodejs010/root/usr/lib64
OPENSHIFT_NODEJS_IDENT=redhat:nodejs:0.10:0.0.17
OPENSHIFT_NODEJS_LOG_DIR=/var/lib/openshift/538f1c205004461655000227/app-root/logs/
OPENSHIFT_NODEJS_IP=127.10.37.129
OPENSHIFT_NODEJS_PID_DIR=/var/lib/openshift/538f1c205004461655000227/nodejs//run/
OPENSHIFT_NODEJS_VERSION=0.10
OPENSHIFT_NODEJS_DIR=/var/lib/openshift/538f1c205004461655000227/nodejs/

and here's what I get for env | grep mongo:

OPENSHIFT_ROCKMONGO_DIR=/var/lib/openshift/538f1c205004461655000227/rockmongo/
PHPRC=/var/lib/openshift/538f1c205004461655000227/rockmongo/etc/conf/php.ini
OPENSHIFT_ROCKMONGO_IDENT=redhat:rockmongo:1.1:0.0.12
OPENSHIFT_MONGODB_IDENT=redhat:mongodb:2.4:0.2.11
OPENSHIFT_MONGODB_DB_URL=mongodb://admin:PASSWORD_HERE@127.10.37.130:27017/
OPENSHIFT_MONGODB_DIR=/var/lib/openshift/538f1c205004461655000227/mongodb/
도움이 되었습니까?

해결책

Just in case someone else stumbles upon this problem, here is what I had to do.

I created separate file config/application.js, and there I placed

module.exports = {
  port: process.env.OPENSHIFT_NODEJS_PORT,
  host: process.env.OPENSHIFT_NODEJS_IP,
  environment: 'production'
};

Also I found what was the problem with application not starting. Post-install was failing (bower install did not finish successfully). To fix it, one should add to scripts section of package.json

"postinstall": "export HOME=/var/lib/openshift/[instance-id]/app-root/runtime/repo; ./node_modules/bower/bin/bower install" 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top