lib/big_brother/app.rb in big_brother-0.3.1 vs lib/big_brother/app.rb in big_brother-0.4.0
- old
+ new
@@ -3,24 +3,28 @@
register Sinatra::Synchrony
set :raise_errors, false
get "/" do
- BigBrother.clusters.map do |name, cluster|
+ clusters = BigBrother.clusters.map do |name, cluster|
"#{cluster}: #{cluster.monitored? ? "running" : "not running"}"
- end.join("\n") + "\n"
+ end.join("\n")
+
+ [200, "Big Brother: #{BigBrother::VERSION}\n\n#{clusters}\n"]
end
before "/cluster/:name" do |name|
@cluster = BigBrother.clusters[name]
halt 404, "Cluster #{name} not found" if @cluster.nil?
end
get "/cluster/:name" do |name|
+ @cluster.synchronize! unless @cluster.monitored?
[200, "Running: #{@cluster.monitored?}"]
end
put "/cluster/:name" do |name|
+ @cluster.synchronize!
halt 304 if @cluster.monitored?
@cluster.start_monitoring!
[200, "OK"]
end