What I Learned Today
I came into work this morning to find SpeakerRate down. It's still not very happy. After rebooting the machine - it wasn't responding to anything - I installed monit on it to monitor it for future issues. I had to search around a lot to find a decent configuration for monit to monitor Apache. I was in a hurry, so I cobbled together what I could find quickly, and ended up with this:
check process apache with pidfile /var/run/apache2.pid
start program = "/etc/init.d/apache2 start"
stop program = "/etc/init.d/apache2 stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 200.0 MB for 5 cycles then restart
if failed host speakerrate.com port 80 protocol http
and request "/"
then alert
if 3 restarts within 5 cycles then timeout
Anyway, while this worked well, SpeakerRate was still lagging, and upon looking further, I found that one of the other apps running on the same machine was taking a lot of CPU and memory. I decided to move SpeakerRate to its own slice, but again, I didn't have a lot of time (obviously - I'm not done yet.) How to provision a slice quickly? I tried Chef, but installing it isn't quick, and seemed really invasive on my server. I think it's made for something much larger-scale than I wanted, which was to get a decent Ruby, MySQL, and Apache configuration set up.
Enter the Sprinkle. If you're provisioning an Ubuntu machine, this thing works wonders. I really like how well it works with Capistrano. I found a great recipe for installing Ruby Enterprise Edition and Phusion Passenger and was set up in no time. I need to dig further to write my own packages, but I managed to make this one for Sphinx pretty easily:
package :sphinx do
description 'Sphinx full-text DB'
version '0.9.8.1'
source "http://www.sphinxsearch.com/downloads/sphinx-#{version}.tar.gz"
verify do
has_file '/usr/local/bin/searchd'
end
end
Published: