Created
January 16, 2011 02:32
-
-
Save peleteiro/781486 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REDIS_VERSION = "2.0.4" | |
task :redis => "redis:start" | |
namespace :redis do | |
task :install do | |
next if File.exist?("#{Rails.root}/vendor/redis/#{REDIS_VERSION}/redis-server") | |
system <<-bash | |
curl http://redis.googlecode.com/files/redis-#{REDIS_VERSION}.tar.gz -o /tmp/redis.tar.gz | |
mkdir -p #{Rails.root}/vendor/redis | |
tar -C #{Rails.root}/vendor/redis -xvzf /tmp/redis.tar.gz | |
mv #{Rails.root}/vendor/redis/redis-#{REDIS_VERSION} #{Rails.root}/vendor/redis/#{REDIS_VERSION} | |
cd #{Rails.root}/vendor/redis/#{REDIS_VERSION} | |
make | |
bash | |
end | |
task :config => :install do | |
File.open("#{Rails.root}/vendor/redis/redis.conf", "w") do |file| | |
file << <<-CONF | |
daemonize no | |
timeout 300 | |
loglevel debug | |
logfile stdout | |
save 900 1 | |
save 300 10 | |
save 60 10000 | |
rdbcompression yes | |
appendonly no | |
appendfsync no | |
dir #{Rails.root}/vendor/redis/ | |
dbfilename dump.rdb | |
CONF | |
end | |
end | |
desc "Runs redis" | |
task :run => :config do | |
if File.exists?("/tmp/redis.dtach") | |
system "dtach -a /tmp/redis.dtach" | |
else | |
system "dtach -c /tmp/redis.dtach #{Rails.root}/vendor/redis/#{REDIS_VERSION}/redis-server #{Rails.root}/vendor/redis/redis.conf" | |
end | |
end | |
desc "Starts redis" | |
task :start => :config do | |
system "dtach -n /tmp/redis.dtach #{Rails.root}/vendor/redis/#{REDIS_VERSION}/redis-server #{Rails.root}/vendor/redis/redis.conf" unless File.exists?("/tmp/redis.dtach") | |
puts "Redis running..." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment