0

I am trying to start my app on openshift. I have push it using git and when I navigate to cd $OPENSHIFT_REPO_DIR and run command npm start everything start successfully and app is running but when I try to start using rch or restarting from openshift website dashboard it give me error

    Stopping NodeJS cartridge
Sun Jun 26 2016 05:58:24 GMT-0400 (EDT): Stopping application 'chat' ...
Sun Jun 26 2016 05:58:25 GMT-0400 (EDT): Stopped Node application 'chat'
Starting NodeJS cartridge
Sun Jun 26 2016 05:58:26 GMT-0400 (EDT): Starting application 'chat' ...
Waiting for application port (8080) become available ...
Application 'chat' failed to start (port 8080 not available)
Failed to execute: 'control restart' for /var/lib/openshift/576ee1c689f5cf9780000123/nodejs

Can someone help me how to solve this problem?

Mišel Ademi
  • 187
  • 4
  • 15

2 Answers2

0

You didn't provide much information. First things first, ssh to your open shift application and check the node log file.

cd $OPENSHIFT_LOG_DIR

Also make sure you are using

process.env.OPENSHIFT_NODEJS_PORT

and

process.env.OPENSHIFT_NODEJS_IP

when you set your application's ip and port properties.

aug70co
  • 3,965
  • 5
  • 30
  • 44
0

You must use env of openshift:

create server.js in root folder:

#!/usr/bin/env node

var express = require('express');
var http = require('http');
var app = express();

// define some router here
.......

var ip = process.env.OPENSHIFT_NODEJS_PORT || 3000;
var port = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';

app.set('port', port);

var server = http.createServer(app);
server.listen(port, ip);

create file .gitignore enter node_modules

Use git update your code.

git add .
git commit -m "First upload project"
git push
Dũng IT
  • 2,751
  • 30
  • 29