Skip to content

Instantly share code, notes, and snippets.

@clifton
Created April 26, 2011 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clifton/943225 to your computer and use it in GitHub Desktop.
Save clifton/943225 to your computer and use it in GitHub Desktop.
diff --git a/config/environments/production.rb b/config/environments/production.rb
index f6124a6..7daf949 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -31,5 +31,10 @@ config.after_initialize do
end
$PAYPAL_LOGIN = $PAYPAL_CONFIG[Rails.env]["api_username"]
$PAYPAL_PASSWORD = $PAYPAL_CONFIG[Rails.env]["api_password"]
-config.cache_store = ActiveSupport::Cache::MemCacheStore.new(Memcached::Rails.new("10.211.47.148:11211", :namespace => "wb_data:"))
-ActionController::Base.cache_store = :mem_cache_store, Memcached::Rails.new("10.211.47.148:11211", :namespace => "wb_data:")
\ No newline at end of file
+config.cache_store = ActiveSupport::Cache::MemCacheStore.new(Memcached::Rails.new("10.211.47.148:11211", :namespace => "wb_data:"))
+$memcached = Memcached::Rails.new("10.211.47.148:11211",
+ :namespace => "wb_data:",
+ :tcp_nodelay => true,
+ :no_block => true)
+ActionController::Base.cache_store = :mem_cache_store, $memcached
+
diff --git a/config/unicorn.rb b/config/unicorn.rb
index f33bff2..18240f6 100644
--- a/config/unicorn.rb
+++ b/config/unicorn.rb
@@ -66,7 +66,7 @@ after_fork do |server, worker|
# Unix forking works, we need to make sure we aren't using any of the parent's
# sockets, e.g. db connection
ActiveRecord::Base.establish_connection
- $memcached.reset if defined?($memcached)
+ $memcached = $memcached.clone if defined?($memcached)
# create a pid file for each worker, god will use this to monitor memory usage
File.open(RAILS_ROOT + "/tmp/pids/uni-worker-#{worker.nr}.pid", 'w') do |f|
diff --git a/config/environments/production.rb b/config/environments/production.rb
index f6124a6..7daf949 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -31,5 +31,10 @@ config.after_initialize do
end
$PAYPAL_LOGIN = $PAYPAL_CONFIG[Rails.env]["api_username"]
$PAYPAL_PASSWORD = $PAYPAL_CONFIG[Rails.env]["api_password"]
-config.cache_store = ActiveSupport::Cache::MemCacheStore.new(Memcached::Rails.new("10.211.47.148:11211", :namespace => "wb_data:"))
-ActionController::Base.cache_store = :mem_cache_store, Memcached::Rails.new("10.211.47.148:11211", :namespace => "wb_data:")
\ No newline at end of file
+config.cache_store = ActiveSupport::Cache::MemCacheStore.new(Memcached::Rails.new("10.211.47.148:11211", :namespace => "wb_data:"))
+$memcached = Memcached::Rails.new("10.211.47.148:11211",
+ :namespace => "wb_data:",
+ :tcp_nodelay => true,
+ :no_block => true)
+ActionController::Base.cache_store = :mem_cache_store, $memcached
+
diff --git a/config/unicorn.rb b/config/unicorn.rb
index f33bff2..18240f6 100644
--- a/config/unicorn.rb
+++ b/config/unicorn.rb
@@ -66,7 +66,7 @@ after_fork do |server, worker|
# Unix forking works, we need to make sure we aren't using any of the parent's
# sockets, e.g. db connection
ActiveRecord::Base.establish_connection
- $memcached.reset if defined?($memcached)
+ $memcached = $memcached.clone if defined?($memcached)
# create a pid file for each worker, god will use this to monitor memory usage
File.open(RAILS_ROOT + "/tmp/pids/uni-worker-#{worker.nr}.pid", 'w') do |f|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment