Tags

When you try to execute the git push command and the deployment status is SUCCESS. However the open shift return an error 503 – Service Temporarily Unavailable

artheman@localmachine /home/mywebappblog (master) $ git push origin master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 341 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: CLIENT_MESSAGE: Stopping Node.js application...
remote: CLIENT_RESULT: Node.js application stopped.
remote: Building git ref 'master', commit 63efa24
remote: CLIENT_RESULT: Node.js modules installed.
remote: Preparing build for deployment
remote: Deployment id is 291b0274
remote: Activating deployment
remote: CLIENT_MESSAGE: Starting Node.js application...
remote: CLIENT_RESULT: Node.js application started.
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
To ssh://123456789@mywebappblog.rhcloud.com/~/git/mywebappblog.git/
   7783eb5..63efa24  master -> master

When accessing the website https://mywebappblog-myaccount.rhcloud.com I got this error Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Solution:
In Express.JS, to fix it make sure that your app properly listen to the correct Port number and IP address. Use process.env.OPENSHIFT_NODEJS_PORT and process.env.OPENSHIFT_NODEJS_IP

/**
 * Get port from environment and store in Express.
 */
var port = process.env.NODE_PORT || process.env.OPENSHIFT_NODEJS_PORT || 4010;
port = normalizePort(port);
var ip = process.env.NODE_IP || process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
app.set('port', port);

var server = http.createServer(app);
server.listen(port, ip); 
server.on('error', onError);
server.on('listening', onListening);
...
...

Note: If using the old node.js version use process.env.NODE_IP & process.env.NODE_PORT otherwise use the process.env.OPENSHIFT_NODEJS_PORT & process.env.OPENSHIFT_NODEJS_IP variables.
That’s it.. it should be working now.

Advertisements