2

I am trying to host a nodeJS app that uses socket.io on OpenShift. I have created the app on openshift, used git clone to get the repo - I then edited server.js to look like this:

#!/bin/env node
var express = require('express');
var app = express()
  , server = require('http').createServer(app)
  , io = require('socket.io').listen(server);

var osipaddress = process.env.OPENSHIFT_NODEJS_IP;
var osport = process.env.OPENSHIFT_NODEJS_PORT;
app.set('port', osport || 8000);
app.set('ipaddress', osipaddress);

/*var pf = require('policyfile').createServer();

pf.listen(10843, function(){
  console.log(':3 yay')
});*/

server.listen(app.get('port'), app.get('ipaddress'), function(){
    console.log('Express server listening on port ' + app.get('port'));
});

app.use(express.static(__dirname + '/'));

app.get('/', function (req, res) {
  res.sendfile(__dirname + '/Startup.html');
});

io.configure(function() {
  io.set('transports', ['websocket','xhr-polling']);
  io.set('flash policy port', 10843);
  //io.set('log level', 1);
});

io.sockets.on('connection', function (socket) {
  socket.on('message', function (data) {
    console.log(data);
  });
});

I then used git commit / git push to make the changes.

When I run rhc tail testapp the output does not produce any errors:

/Users/Eamon/.rvm/gems/ruby-2.0.0-p0/gems/highline-1.6.21/lib/highline/system_extensions.rb:230: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
DEBUG: Running node-supervisor with
DEBUG:   program 'server.js'
DEBUG:   --watch '/var/lib/openshift/53a2e6275973ca689c000060/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/53a2e6275973ca689c000060/app-root/data/.nodewatch' for changes.
info: socket.io started
Express server listening on port 8080

However, when I visit the site - I still see the initial welcome page (as if I had not pushed any code) - http://testapp-eamonbenproject.rhcloud.com/

Any ideas? As I am not really getting errors, I am not sure where to start.

ewizard
  • 2,801
  • 4
  • 52
  • 110

1 Answers1

2

Startup.html needed to be named index.html for openshift to work correctly.

ewizard
  • 2,801
  • 4
  • 52
  • 110