Sha256: 7bc6ae092fd42daee8d766d4932a0aaa7b07fa5cbd82f187dadea5ab1fd22bd3
Contents?: true
Size: 1.07 KB
Versions: 5
Compression:
Stored size: 1.07 KB
Contents
module RedisRing class Shard attr_reader :shard_config, :pid def initialize(shard_config) @shard_config = shard_config @status = :stopped end def shard_number shard_config.shard_number end def host shard_config.host end def port shard_config.port end def status if @status == :stopped return alive? ? :stopping : :stopped elsif @status == :started return alive? ? :running : :dead else raise RuntimeException.new("Unknown status: #{@status.inspect}") end end def start if @status == :started @task.start unless @task.running? else shard_config.save @task = fork_redis_server @status = :started end end def stop @task.stop @status = :stopped end def alive? @task && @task.running? end protected def fork_redis_server Daemons.call(:multiple => true) do exec(shard_config.redis_path, shard_config.config_file_name) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems