diff options
author | Saku Ytti <saku@ytti.fi> | 2013-04-19 12:36:45 +0300 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2013-04-19 12:41:29 +0300 |
commit | 96668cc2dc0367e3d1a3ec94265ce889b62d8ada (patch) | |
tree | 340f92a6dd4b68e41a946729c8fae34db7aff40b /lib/oxidized/core.rb | |
parent | 9d217025fac3e335c308f02e7377e14ccfdc0e66 (diff) |
Add restful API
Diffstat (limited to 'lib/oxidized/core.rb')
-rw-r--r-- | lib/oxidized/core.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/oxidized/core.rb b/lib/oxidized/core.rb index 76aa330..59292f9 100644 --- a/lib/oxidized/core.rb +++ b/lib/oxidized/core.rb @@ -4,6 +4,7 @@ module Oxidized require 'oxidized/worker' require 'oxidized/nodes' require 'oxidized/manager' + require 'oxidized/api/rest' class << self def new *args Core.new args @@ -14,8 +15,18 @@ module Oxidized def initialize args Oxidized.mgr = Manager.new nodes = Nodes.new - worker = Worker.new nodes - loop { worker.work; sleep 1 } + @worker = Worker.new nodes + @rest = API::Rest.new nodes, CFG.rest if CFG.rest + run + end + + private + + def run + while true + @worker.work + @rest ? @rest.work : sleep(Config::Sleep) + end end end end |