Sha256: 9b0e98645ddddaae76aca8da1b40271333e1c591410de621e4f8cf27773bb852

Contents?: true

Size: 1.66 KB

Versions: 13

Compression:

Stored size: 1.66 KB

Contents

REDIS_RELEASE = "2.4.10"

class RedisRunner
  
  def self.prefix
    "/usr/local/"
  end

  def self.redisdir
    "/tmp/redis/"
  end

  def self.redisconfdir
    server_dir = File.dirname(`which redis-server`)
    conf_file = "#{RedisRunner.prefix}etc/redis.conf"
    unless File.exists? conf_file
      conf_file = "#{server_dir}/redis.conf"
    end
    conf_file
  end

  def self.dtach_socket
    '/tmp/redis.dtach'
  end

  # Just check for existance of dtach socket
  def self.running?
    File.exists? dtach_socket
  end

  def self.start
  	if windows?
  		puts "Starting redis in a new window..."
  		system "start #{File.join(redis_home,'redis-server')} #{File.join(redis_home,'redis.conf')}" rescue
  			"redis-server not installed on your path, please run 'rhoconnect redis-install' first."
    elsif defined?(JRUBY_VERSION)
      puts "Starting redis ..."
      system "redis-server #{redisconfdir}"
    else
      puts 'Detach with Ctrl+\  Re-attach with rhoconnect redis-attach'
      sleep 1
      command = "dtach -A #{dtach_socket} redis-server #{redisconfdir}"
      system command
    end
  end
  
  # this function is used with Rhostudio where there is no terminal
  def self.startbg
  	if windows?
  		puts "Starting redis in a new window..."
  		system "start #{File.join(redis_home,'redis-server')} #{File.join(redis_home,'redis.conf')}" rescue
  			"redis-server not installed on your path, please run 'rhoconnect redis-install' first."
    else
      puts "Starting redis ..."
      system "redis-server #{redisconfdir} &"
    end
  end

  def self.attach
    system "dtach -a #{dtach_socket}"
  end

  def self.stop
    Redis.new.shutdown rescue nil
  end

end #RedisRunner

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rhoconnect-3.3.6 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.3.5 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.3.4 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.3.3 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.3.2 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.3.1 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.3.1.beta4 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.3.1.beta3 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.3.1.beta2 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.2.1 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.2.0 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.2.0.beta5 commands/commands/redis_commands/redis_runner.rb
rhoconnect-3.2.0.beta4 commands/commands/redis_commands/redis_runner.rb