lib/redis_ring/shard.rb in redis_ring-0.0.1 vs lib/redis_ring/shard.rb in redis_ring-0.0.2
- old
+ new
@@ -30,31 +30,33 @@
raise RuntimeException.new("Unknown status: #{@status.inspect}")
end
end
def start
- shard_config.save
- @pid = fork_redis_server
- @status = :started
+ if @status == :started
+ @task.start unless @task.running?
+ else
+ shard_config.save
+ @task = fork_redis_server
+ @status = :started
+ end
end
def stop
- send_kill_signal
+ @task.stop
@status = :stopped
end
- protected
-
def alive?
- @pid && File.exist?("/proc/#{@pid}")
+ @task && @task.running?
end
- def fork_redis_server
- spawn(shard_config.redis_path, shard_config.config_file_name)
- end
+ protected
- def send_kill_signal
- system("kill -QUIT #{pid}")
+ def fork_redis_server
+ Daemons.call(:multiple => true) do
+ exec(shard_config.redis_path, shard_config.config_file_name)
+ end
end
end
end