Here are the steps I followed to upgrade our flagship product.
Steps I had to take on the git repos:
verify that rake version is 0.8.4 and rubygems is 1.3.1
rm -rf vendor/rails
gem update rails rack
cd vendor && git clone git://github.com/rails/rails.git
cd rails && grb track 2-3-stable
git checkout 2-3-stable
rm -rf .git
cd ~/
modify environment.rb to user rails 2.3.2
rake rails:update
git add -A
Upgrade issues I ran into:
# check plugins/gems that need to be updated
# mocha
5076 rollbook:master+! % rake test:units
rake aborted!
can't activate mocha (= 0.9.4, runtime), already activated mocha-0.9.5
# move "require 'mocha'" from test/test_helper.rb into config/environments/test.rb
# http://gist.github.com/111060 -- solution: remove "require 'ar-extensions" from config/initializers/.rb
# remove all references to Test::Unit http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/f90ecdba834c2ef8/f204e834e5e0303c?lnk=raot in test dir
# replace Test::Unit w/ActiveRecord or ActionController as appropriate
# replace CGI::Session.generate_unique_id w/ActiveSupport::SecureRandom.hex(16)
# updated hoptoad and shoulda
# add xmlsimple to be required
# updated new_relic agent
# install country_select plugin
Steps to be take on the production server:
# update passenger 2.2.2
# gem update rails rack
Leave the first comment ▶
Updated 2008/09/24 for latest version of backgroundrb 1.0.4
The other day on our staging server, I noticed that the BackgrounDRb queue worker had died. As it turned out, the queue worker had died over 3 months ago!!
There was no cause for alarm as the staging server isn’t critical but this did start me to worrying. We needed to implement a monitoring solution which not only verified that BackgrounDRb was running but also that particular workers were running.
As we had just implemented god monitoring with a custom condition for another issue, its a slam dunk to do the same again. (Thanks to Jesse Newland and his god tutorial at AtlRUG.)
Here’s the configuration file that got it done for us.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
| #run on command line with 'god -c backgroundrb.god -D'
RAILS_ROOT = '/var/www/rails/rollbook/current'
#load required rails and backgroundrb files
require File.dirname(__FILE__) + '/../boot'
require File.dirname(__FILE__) + '/../environment'
require 'erb'
$LOAD_PATH << "#{RAILS_ROOT}/vendor/plugins/backgroundrb/lib"
require "#{RAILS_ROOT}/vendor/plugins/backgroundrb/lib/backgroundrb.rb"
#create custom condition for checking that QueryProcessingWorker is running
MiddleMan = BackgrounDRb::ClusterConnection.new
module God
module Conditions
class Backgroundrb < PollCondition
def initialize; super; end
def valid?; true; end
def test
begin
queue_worker = MiddleMan.all_worker_info.values.flatten.select { |w| :queue_processing_worker == w[:worker] }
queue_worker.empty?
rescue #if all_worker_info raises exception, then bdrb isn't running and we were unable to connect
true
end
end
end
end
end
God.watch do |w|
w.name = 'backgroundrb'
w.interval = 1.minute
w.restart = "cd #{RAILS_ROOT} && #{RAILS_ROOT}/script/backgroundrb -e production stop && #{RAILS_ROOT}/script/backgroundrb -e production start"
w.stop = "cd #{RAILS_ROOT} && #{RAILS_ROOT}/script/backgroundrb -e production stop"
w.start = "cd #{RAILS_ROOT} && #{RAILS_ROOT}/script/backgroundrb -e production start"
w.grace = 1.minute
w.pid_file = "#{RAILS_ROOT}/tmp/pids/backgroundrb_11000.pid"
w.start_if do |start|
start.condition(:process_running) do |c|
c.running = false
end
end
w.restart_if do |restart|
restart.condition(:backgroundrb) do |c|
#just restart it
end
end
end |
In the select call on line 21, you can modify the condition to access :job_key or :status as well. Obviously, you need to modify RAILS_ROOT for your situation.
If you have suggestions for improvement or questions, hit me up in the comments. Enjoy!
3 comments so far, add yours ▶
Ack has this nice colorized output when searching code files. Some may say that grep can do the same thing (it can), but there’s no need for arg’ing it up with ack. There’s a similar ruby version, rak, but I’ve heard it isn’t quite as fast as ack. Ack works well enough for me and the install process isn’t that painful.
There’s two ways to install listed over at ack; I chose the CPAN route (since I never know when I’ll need to install some more perl goodies).
How to install ack on Mac OS X leopard in 3 easy steps.
- install mac ports
- sudo port install perl5.8
- sudo cpan -i App::Ack
One comment so far, add another ▶