Sha256: 9f75a6444ec053220f01b75456d373e6fff537b83de89a31a31370ba173ab08a

Contents?: true

Size: 876 Bytes

Versions: 15

Compression:

Stored size: 876 Bytes

Contents

require 'fileutils'

class RedisCluster
  
  def initialize(opts={})
    opts = {:port => 6379, :host => 'localhost', :basedir => "#{Dir.pwd}/rdsrv" }.merge(opts)
    FileUtils.mkdir_p opts[:basedir]
    opts[:size].times do |i|
      port = opts[:port] + i
      FileUtils.mkdir_p "#{opts[:basedir]}/#{port}"
      File.open("#{opts[:basedir]}/#{port}.conf", 'w'){|f| f.write(make_config(port, "#{opts[:basedir]}/#{port}", "#{opts[:basedir]}/#{port}.log"))}
      system(%Q{#{File.join(File.expand_path(File.dirname(__FILE__)), "../redis/redis-server #{opts[:basedir]}/#{port}.conf &" )}})
    end  
  end

  def make_config(port=6379, data=port, logfile='stdout', loglevel='debug')
    config = %Q{
timeout 300
save 900 1
save 300 10
save 60 10000
dir #{data}
loglevel #{loglevel}
logfile #{logfile}
databases 16
port #{port}
    }
  end
  
end


RedisCluster.new :size => 4

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
adamwiggins-redis-rb-0.1.1 bin/distredis
lunar-0.4.1 vendor/redis/bin/distredis
lunar-0.4.0 vendor/redis/bin/distredis
lunar-0.3.0 vendor/redis/bin/distredis
lunar-0.2.3 vendor/redis/bin/distredis
lunar-0.2.2 vendor/redis/bin/distredis
lunar-0.2.1 vendor/redis/bin/distredis
lunar-0.2.0 vendor/redis/bin/distredis
lunar-0.1.1 vendor/redis/bin/distredis
lunar-0.1.0 vendor/redis/bin/distredis
vanity-1.3.0 vendor/redis-rb/bin/distredis
mikeg-vanity-1.3.0 vendor/redis-rb/bin/distredis
vanity-1.2.0 vendor/redis-rb/bin/distredis
vanity-1.1.1 vendor/redis-rb/bin/distredis
vanity-1.1.0 vendor/redis-rb/bin/distredis