X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/ed9b544e10b84cd43348ddfab7068b610a5df1f7..5762b7f0f8d33eda021da908b6ddced684a2ba05:/client-libraries/ruby/tasks/redis.tasks.rb diff --git a/client-libraries/ruby/tasks/redis.tasks.rb b/client-libraries/ruby/tasks/redis.tasks.rb index 67b9499f..ed317d38 100644 --- a/client-libraries/ruby/tasks/redis.tasks.rb +++ b/client-libraries/ruby/tasks/redis.tasks.rb @@ -1,5 +1,6 @@ # Inspired by rabbitmq.rake the Redbox project at http://github.com/rick/redbox/tree/master require 'fileutils' +require 'open-uri' class RedisRunner @@ -31,7 +32,7 @@ class RedisRunner end def self.stop - sh 'killall redis-server' + sh 'echo "SHUTDOWN" | nc localhost 6379' end end @@ -52,17 +53,26 @@ namespace :redis do task :stop do RedisRunner.stop end + + desc 'Restart redis' + task :restart do + RedisRunner.stop + RedisRunner.start + end desc 'Attach to redis dtach socket' task :attach do RedisRunner.attach end - desc 'Install the lastest redis from svn' + desc 'Install the lastest verison of Redis from Github (requires git, duh)' task :install => [:about, :download, :make] do - sh 'sudo cp /tmp/redis/redis-server /usr/bin/' - sh 'sudo cp /tmp/redis/redis-benchmark /usr/bin/' - puts 'Installed redis-server and redis-benchmark to /usr/bin/' + %w(redis-benchmark redis-cli redis-server).each do |bin| + sh "sudo cp /tmp/redis/#{bin} /usr/bin/" + end + + puts "Installed redis-benchmark, redis-cli and redis-server to /usr/bin/" + unless File.exists?('/etc/redis.conf') sh 'sudo cp /tmp/redis/redis.conf /etc/' puts "Installed redis.conf to /etc/ \n You should look at this file!" @@ -76,8 +86,9 @@ namespace :redis do desc "Download package" task :download do - system 'svn checkout http://redis.googlecode.com/svn/trunk /tmp/redis' unless File.exists?(RedisRunner.redisdir) - system 'svn up' if File.exists?("#{RedisRunner.redisdir}/.svn") + sh 'rm -rf /tmp/redis/' if File.exists?("#{RedisRunner.redisdir}/.svn") + sh 'git clone git://github.com/antirez/redis.git /tmp/redis' unless File.exists?(RedisRunner.redisdir) + sh "cd #{RedisRunner.redisdir} && git pull" if File.exists?("#{RedisRunner.redisdir}/.git") end end @@ -96,10 +107,8 @@ namespace :dtach do unless File.exists?('/tmp/dtach-0.8.tar.gz') require 'net/http' - Net::HTTP.start('superb-west.dl.sourceforge.net') do |http| - resp = http.get('/sourceforge/dtach/dtach-0.8.tar.gz') - open('/tmp/dtach-0.8.tar.gz', 'wb') do |file| file.write(resp.body) end - end + url = 'http://downloads.sourceforge.net/project/dtach/dtach/0.8/dtach-0.8.tar.gz' + open('/tmp/dtach-0.8.tar.gz', 'wb') do |file| file.write(open(url).read) end end unless File.directory?('/tmp/dtach-0.8') @@ -113,4 +122,4 @@ namespace :dtach do puts 'Dtach successfully installed to /usr/bin.' end end - \ No newline at end of file +