1

I've inherited a Rails 3.2 production environment which is 'humming' away nicely.

The client now wants another major piece of work doing but I want to do it in Rails 5. The web address would be the same for both the old site and the new project. The new project would be additional functionality which would be accessed via the old site.

Any one know of a way of keeping the old site running whilst I develop and deliver the new work via Rails 5? Eventually if this all works then I get the opportunity to migrate the old site to Rails 5. However for the moment I need to serve up both Rails 3.2 and Rails 5 from the same site.

halfer
  • 19,824
  • 17
  • 99
  • 186
nexar
  • 11,126
  • 3
  • 29
  • 32

2 Answers2

1

It's possible to do what you describe with a reverse proxy, e.g. nginx, configured to serve from different web servers based on different paths on the same host. This answer has some details on how to do that. We would need to know how your website is hosted in order to give more details on exactly how to do that.

However, there are other concerns that come up when you start separating your apps which you may not have considered. For example, if your website allows users to log in, do you want them to still be logged in when they visit the new site? To do so transparently will require sharing the session cookie, which this post describes a bit (you'll need to use the same secret key for both apps, or use a remote session store like Memcached). I'm not sure if it'll work properly when shared between Rails 3.2 and 5, though.

As a final note, breaking up your monolithic app into a distributed system is never a decision to take lightly. It would likely end up being less work, and less overall architectural overhead, to simply invest the time in upgrading from 3.2 -> 4.0 -> 4.2 -> 5.0.

Community
  • 1
  • 1
Robert Nubel
  • 7,104
  • 1
  • 18
  • 30
  • many thanks for your prompt answer. The way I need this to work is that I develop new project in Rails 5 and then have a menu option within the Rails 3.2 system which points to the controller within Rails 5. OK!! That's what I IDEALLY want but I'm willing to live with a hack. Regarding the upgrade, that is not my decision / remit right now. I need to have my new project 'appear' to seamlessly work from the old system. I ran into something similar a few years back (ended up not getting the project though) but during the research I remember reading something about using RACK to solve it. – nexar Apr 28 '17 at 16:06
  • I can't find the link to that though. – nexar Apr 28 '17 at 16:11
  • I did something similar a while back but with Javascript. I had different UI versions of the development environment and all I had to do was leave all the old stuff pointing to the old UI scripts and as I created new screens I pointed them to the new UI scripts. Worked a treat. That's the kind of thing I was hoping for with Rails too. – nexar Apr 28 '17 at 16:17
  • The old website is hosted on Ubunt 16.04 with Rails 3.2 and ruby 1.9 (I believe). It uses DHTMLX as it's javascript front end and the Rails serves up the javascript along with any data in XML format. The site doesn't use sessions AT ALL. It maintains an independent table of logged in users and passes tokens backwards and forwards which allow it to 'understand' state. Personally I thought that was one of the better bits of the system. LOL. – nexar Apr 28 '17 at 16:20
  • JS is a different beast; dependencies in a JS project can be isolated so you can have one page depend on as many versions of a library as you want. But Ruby processes must agree on one common set of dependencies. So, I would suggest spinning up two instances of Rails -- one for each project -- and using nginx to reverse proxy between them based on the route. E.g. `yourwebsite.com/` routes to old, `yourwebsite.com/new` routes to new. – Robert Nubel Apr 28 '17 at 17:35
  • Robert thanks very much for your response. I'll try out the multiple Rails with routes option on nginx and see how I get on. – nexar Apr 29 '17 at 09:11
0

Personally I wouldn't touch that old app and its server, especially if the client is happy. Deploying the new app to a new server or a container service like heroku is something you should consider.

Thomas R. Koll
  • 3,131
  • 1
  • 19
  • 26