Deploying Rails: Automate, Deploy, Scale, Maintain, and Sleep at Night (The Facets of Ruby)

Deploying Rails: Automate, Deploy, Scale, Maintain, and Sleep at Night (The Facets of Ruby)

Language: English

Pages: 240

ISBN: 1934356956

Format: PDF / Kindle (mobi) / ePub


Today's modern Rails applications have lots of moving parts. Make sure your next production deployment goes smoothly with this hands-on book, which guides you through the entire production process. You'll set up scripts to install and configure all the software your servers need, including your application code. Once you're in production, you'll learn how to set up systems to monitor your application's health, gather metrics so you can stop problems before they start, and fix things when they go wrong.

Deploying Rails takes you on a expertly guided tour of the current best practices in Rails deployment and management. You'll find in-depth explanations on effectively running a Rails app by leveraging popular open source tools such as Puppet, Capistrano, and Vagrant. Then you'll go beyond deployment and learn how to use Ganglia and Nagios to monitor your application's health and gather metrics so you can head off problems before they happen.

You'll start out by building your own virtual environment by writing scripts to provision a production server with Vagrant and Puppet. Then you'll leverage the popular Rails deployment tool Capistrano to deploy an application into this infrastructure. Once the app is live, you'll monitor your application's health with Nagios, and configure Ganglia to collect system metrics. Finally, you'll see how to keep your data backed up, recover data when things go wrong, tame your log files, and use Puppet to automate everything along the way.

Whether you're a Rails developer who wants a better understanding of the needs of a production Rails system, if you're a system administrator who wants to manage a Rails application, or if you're bridging the gap between development and operations, this book will be your roadmap to successful production deployment and maintenance, whether your application has ten users or ten million users.

What You Need:

The exercises and examples are most suited to a computer running some Unix variant, such as Mac OS X or Linux. But a Windows machine running Linux in a VirtualBox virtual machine is also sufficient.

We'll show you how to set up a local virtual machine for your deployments; you won't need a dedicated server to hone your deployment skills. We expect you to have a basic familiarity with the Ruby programming language, the Ruby on Rails framework, and the Unix command line.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

10.1 Managing Crontab with Whenever 10.2 Backing Up Everything 10.3 Using Ruby Enterprise Edition 10.4 Securing sshd 10.5 Conclusion . . . . . 185 185 188 193 196 197 A1. A Capistrano Case Study . A1.1 Requires and Variables A1.2 Hooks and Tasks . . . . . . 199 199 201 A2. Running on Unicorn and nginx . . . A2.1 Installing and Configuring nginx A2.2 Running MassiveApp on Unicorn A2.3 Deploying to nginx and Unicorn A2.4 Where to Go Next . . . . . 205 206 208 209 210 . .

Finished catalog run in 0.12 seconds Our module is working; Puppet has overwritten the file, and we’re back to our desired configuration. We’ve seen Puppet modules in action now, so let’s pause and review a few things about using them. • A module lives in Puppet’s modules directory. • A module directory is named after the service or resource that it provides. • A module needs an init.pp file containing its resource declarations in the modules/module_name/manifests directory. • Our

our Current Users service check showing green for app. We can run local and remote checks, so our Nagios coverage is improving quickly. Next we’ll define a new service check for memcached that uses the NRPE daemon that we just configured. Monitoring Memcached Remotely We need a monitoring check for memcached that uses NRPE, so over on app let’s open up modules/nagios/files/nrpe.cfg and add the following command definition: command[check_memcached]=/usr/lib/nagios/plugins/check_tcp \ -p 11211 -e

a good one written by Vladimir Vuksan.4 Let’s grab that file using curl and put it in the modules/ganglia/files/gmetric directory on app. app $ mkdir modules/ganglia/files/gmetric app $ curl --silent --output modules/ganglia/files/gmetric/ganglia_mysql_stats.pl \ https://raw.github.com/ganglia/gmetric\ /master/database/mysql_stats/ganglia_mysql_stats.pl Before we use this plugin, we need to ensure that it can connect to the MassiveApp MySQL database. Let’s open the script and move down to line

the page load time exceeds some threshold. Busywork doesn’t mean that the work being done is simple. That iptables configuration may be the result of hours of skillful tuning and tweaking. It turns into busywork only when we have to type the same series of commands each time we have to roll it out to a new server. We want repeatability; we want to be able to roll a change out to dozens of servers in a few seconds with no fear of making typos or forgetting a step on each server. We’d also like to

Download sample

Download