Class: BackgroundQueue::ServerLib::EventServer
- Inherits:
-
Object
- Object
- BackgroundQueue::ServerLib::EventServer
- Defined in:
- lib/background_queue/server_lib/event_server.rb
Instance Attribute Summary collapse
-
#running ⇒ Object
readonly
Returns the value of attribute running.
Instance Method Summary collapse
-
#initialize(server) ⇒ EventServer
constructor
A new instance of EventServer.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(server) ⇒ EventServer
Returns a new instance of EventServer.
10 11 12 13 |
# File 'lib/background_queue/server_lib/event_server.rb', line 10 def initialize(server) @server = server @running = false end |
Instance Attribute Details
#running ⇒ Object (readonly)
Returns the value of attribute running.
8 9 10 |
# File 'lib/background_queue/server_lib/event_server.rb', line 8 def running @running end |
Instance Method Details
#start ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/background_queue/server_lib/event_server.rb', line 15 def start EventMachine.run do EventMachine::start_server(@server.config.address.host, @server.config.address.port, BackgroundQueue::ServerLib::EventConnection) do |conn| conn.server = @server end @scheduler = Rufus::Scheduler::EmScheduler.new @scheduler.start for job in @server.config.jobs job.schedule(@scheduler, @server) end @running = true end @running = false end |
#stop ⇒ Object
31 32 33 |
# File 'lib/background_queue/server_lib/event_server.rb', line 31 def stop EventMachine::stop if EventMachine::reactor_running? end |