Skip to content
Browse files

Add memcached tasks and update config to match

  • Loading branch information...
1 parent 0bf6d9e commit 3a9a4fbcc3aae1d6303a60b7d32f5e2dd9d35027 @markjaquith committed Jun 5, 2012
Showing with 26 additions and 1 deletion.
  1. +12 −1 Capistrano/config/SAMPLE.config.rb
  2. +14 −0 Capistrano/lib/tasks.rb
View
13 Capistrano/config/SAMPLE.config.rb
@@ -9,4 +9,15 @@
# Using Git Submodules?
set :git_enable_submodules, 1
-role :web, "your web-server here"
+# role :web, "your web server here"
+# role :web, "second web server here"
+# role :web, "third web server here, etc"
+
+# role :memcached, "your memcached server here"
+# role :memcached, "second memcached server here, etc"
+
+# Alternatively, if your web servers are the same as your memcached servers,
+# comment out all the "role" lines and use "server" lines:
+
+# server "your web/memcached server here", :web, :memcached
+# server "second web/memcached server here", :web, :memcached
View
14 Capistrano/lib/tasks.rb
@@ -28,3 +28,17 @@
run "if [ -d #{shared_path}/cached-copy/ ]; then cd #{shared_path}/cached-copy/ && git submodule foreach --recursive git fetch origin --tags; fi"
end
end
+
+namespace :memcached do
+ desc "Restarts Memcached"
+ task :restart do
+ run "echo 'flush_all' | nc localhost 11211", :roles => [:memcached]
+ end
+ desc "Updates the pool of memcached servers"
+ task :update do
+ mc_servers = '<?php return array( "' + find_servers( :roles => :memcached ).join( ':11211", "' ) + ':11211" ); ?>'
+ shared.make_shared_dir
+ run "echo '#{mc_servers}' > #{release_path}/memcached.php", :roles => :memcached
+ end
+end
+

0 comments on commit 3a9a4fb

Please sign in to comment.
Something went wrong with that request. Please try again.