diff options
author | Saku Ytti <saku@ytti.fi> | 2014-02-23 19:11:29 +0200 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2014-02-23 19:11:29 +0200 |
commit | 8880188001da23a5f0960e3970c4eb9bbd448306 (patch) | |
tree | 41a1f79450ff1683a2d5aa1f024a564e84230e25 /lib/oxidized/api/web.rb | |
parent | 06e5f68db6cfcbd80295874db1f00a25e8ba1229 (diff) |
Migrate to sinatra/puma from webrick
As I can't do IO#select on sinatra/puma to run it when I have time, I
have to run it on separate thread.
This means Nodes container needs to be thread safe, it now has ghetto
mutex locking, but I probably need to be be more focused what are the
external methods that can be called and wrap those in @mutex.synchronize
Provide also HTML UI not just JSON for ghetto UI to people who don't want to
integrate
Diffstat (limited to 'lib/oxidized/api/web.rb')
-rw-r--r-- | lib/oxidized/api/web.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/oxidized/api/web.rb b/lib/oxidized/api/web.rb new file mode 100644 index 0000000..9a5a507 --- /dev/null +++ b/lib/oxidized/api/web.rb @@ -0,0 +1,19 @@ +module Oxidized + module API + class Web + attr_reader :thread + def initialize nodes, listen + require 'oxidized/api/web/webapp' + addr, port = listen.to_s.split ':' + port, addr = addr, nil if not port + WebApp.set :server, %w(puma) + WebApp.set :bind, addr if addr + WebApp.set :port, port + WebApp.set :nodes, nodes + end + def run + @thread = Thread.new { WebApp.run! } + end + end + end +end |