Skip to content

Commit

Permalink
added Thin server and refactored the HOBSON_REDIS_SLAVE option to wor…
Browse files Browse the repository at this point in the history
…k both with vegas and rack
  • Loading branch information
Jared Grippe authored and jaredatron committed Jun 11, 2012
1 parent 07f2583 commit c4d5984
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -24,4 +24,5 @@ group :development, :test do
gem 'rake'
gem 'rspec'
gem 'resque_unit'
gem 'thin'
end
7 changes: 7 additions & 0 deletions Gemfile.lock
Expand Up @@ -65,8 +65,10 @@ GEM
childprocess (0.3.1)
ffi (~> 1.0.6)
columnize (0.3.6)
daemons (1.1.4)
diff-lcs (1.1.3)
erubis (2.7.0)
eventmachine (0.12.10)
excon (0.13.4)
ffi (1.0.11)
fog (1.3.1)
Expand Down Expand Up @@ -166,6 +168,10 @@ GEM
tilt (~> 1.1, != 1.3.0)
sys-proctable (0.9.1)
systemu (2.4.2)
thin (1.3.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.14.6)
tilt (1.3.3)
uuid (2.3.5)
Expand All @@ -187,3 +193,4 @@ DEPENDENCIES
ruby-debug-base19x (~> 0.11.30.pre4)
ruby-debug19
shotgun
thin
3 changes: 3 additions & 0 deletions config.ru
Expand Up @@ -2,4 +2,7 @@ require 'rubygems'
require 'bundler/setup'
require File.expand_path('../lib/hobson', __FILE__)

Hobson.log_to_stdout!
Hobson.use_redis_slave!
Hobson.log_redis!
run Hobson::Server
5 changes: 5 additions & 0 deletions lib/hobson/redis.rb
Expand Up @@ -62,6 +62,7 @@ def redis_slave
end

def use_redis_slave!
return if ENV['HOBSON_REDIS_SLAVE'] == 'false'
begin
redis_slave.balancer.keys
rescue Errno::ECONNREFUSED, RuntimeError
Expand Down Expand Up @@ -97,4 +98,8 @@ def enable_redis_benchmarker!
@redis
end

def log_redis!
root_redis.client.logger = Hobson.logger
end

end
2 changes: 1 addition & 1 deletion lib/hobson/server.rb
Expand Up @@ -20,7 +20,7 @@ class Hobson::Server < Sinatra::Base
class Runner < Vegas::Runner
def check_for_running path=nil
super
Hobson.use_redis_slave! unless ENV['HOBSON_REDIS_SLAVE'] == 'false'
Hobson.use_redis_slave!
end
end

Expand Down

0 comments on commit c4d5984

Please sign in to comment.