Class: RedisRing::WebInterfaceRunner

Inherits:
Object
  • Object
show all
Includes:
BackgroundThread
Defined in:
lib/redis_ring/web_interface.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BackgroundThread

#after_halt, #before_run, #continue_running?, #run

Constructor Details

#initialize(port, master, slave) ⇒ WebInterfaceRunner

Returns a new instance of WebInterfaceRunner.



9
10
11
12
13
# File 'lib/redis_ring/web_interface.rb', line 9

def initialize(port, master, slave)
  @port = port
  @master = master
  @slave = slave
end

Instance Attribute Details

#masterObject (readonly)

Returns the value of attribute master.



7
8
9
# File 'lib/redis_ring/web_interface.rb', line 7

def master
  @master
end

#slaveObject (readonly)

Returns the value of attribute slave.



7
8
9
# File 'lib/redis_ring/web_interface.rb', line 7

def slave
  @slave
end

Instance Method Details

#do_workObject



15
16
17
18
19
20
21
22
23
# File 'lib/redis_ring/web_interface.rb', line 15

def do_work
  handler = Rack::Handler.get("webrick")
  handler.run(WebInterface, :Port => @port, :master => @master, :slave => @slave) do |server|
    @server = server
    WebInterface.set :master, master
    WebInterface.set :slave, slave
    WebInterface.set :running, true
  end
end

#haltObject



25
26
27
28
# File 'lib/redis_ring/web_interface.rb', line 25

def halt
  super
  @server.stop if @server
end