Recently, I had my first real experience with deploying a (small) web application. I had to perform a pretty wide research and torture some experienced people with handling the difficulties. I gained knowledge that I consider worth sharing. Let me describe configuration of deployment stack and scripts created for the aforementioned app.

The app is a Ruby on Rails application built with JRuby.

Main characteristics:

  • Nginx – web server
  • Puma – application server
  • Mina – deployment automation tool
  • Monit – processes monitoring tool
  • JRuby – Ruby implemented in Java and executed on Java Virtual Machine

Nginx was already installed and configured by a sysadmin. I’d like to focus on the Mina, Puma and Monit configuration…

Theory

… but a little theory first. Let me tell you very short and abstract story of how a HTTP server handles requests as well as everything you need to know to understand my deployment setup.

HTTP requests

HTTP requests hit the machine and the first guy they meet is the web server. Most popular are Nginx and Apache. Let’s use Nginx as example for further part of the story. Based on the request’s target domain and path, web server dispatches each request to proper applications hosted by the current machine. To notify Nginx about application server which should be accessible from the Internet, we have to describe it using a server directive. This directive is used for routing requests to other servers and applicaton server is only a name for another web server with specific responsibilities.

Routed requests meet another web server, specific for the application. Example application server for Rails apps is Puma. It leads requests to the Rails application. Rails holds the connection with the database server, etc. and does its job to respond on a given request.

HTTP request visualisation

#jruby rails #puma #mina #moni #ruby/rails #development

Deployment setup for JRuby Rails app with Puma, Mina and Moni
26.45 GEEK