Deploying Rails and Nodejs

I wrote a live web application consisting of the following:

  • Rails for serving web pages (listening on port 80)
  • Nodejs handles realtime logic (listening on port 8888)

This way, on the specific page served by my rails app, the JS will use socket.io to establish a connection to my nodejs instance to allow realtime HTTP push.

Currently Nodejs communicates with Rails by simply updating the rails database. (I know this is a ghetto , but it works).

What are my deployment options?

  • I used to deploy simple web applications to heroku and I really like the simplicity.
  • I have also deployed a web app with similar functionality (besides one consisting of django + nodejs). I used HAProxy for reverse proxying to handle routing traffic to the correct process on my machine. However, I have deployed this to a VPS server.

Note: the ugliness is likely to revolve around:

  • I rely on shared db
  • These processes are listening on different ports
+3


source to share


2 answers


We had this exact problem. We deployed them to split Heroku apps, but kept them in the same codebase. http://techtime.getharvest.com/blog/deploying-multiple-heroku-apps-from-a-single-repo describes how to do this.

Custom script in bin / web



#!/bin/bash

if [ "$RAILS_DEPLOYMENT" == "true" ]; then
  bundle exec rails server -p $PORT
else
  node node/index.js
fi

      

And the Procfile:

web: bin/web

      

+1


source


I would consider installing these two applications as separate Heroku applications on different subdomains and just both of them on port 80. The communication between them goes through a common database, so they don't need to be on the same machine or even Data Center. Socket.io supports cross-domain requests in all browsers, so this shouldn't cause any problems.



0


source







All Articles