Sha256: 52007c489fb77ebabb3c33f737613f242aa266f11aee92f6218e5d7fb97715d4
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module BigBrother class App < Sinatra::Base register Sinatra::Synchrony set :raise_errors, false get "/" do clusters = BigBrother.clusters.map do |name, cluster| "#{cluster}: #{cluster.monitored? ? "running" : "not running"}" 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 delete "/cluster/:name" do |name| halt 304 unless @cluster.monitored? @cluster.stop_monitoring! [200, "OK"] end error do e = request.env['sinatra.error'] BigBrother.logger.info "Error: #{e}" BigBrother.logger.info e.backtrace.join("\n") 'Application error' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
big_brother-0.4.0 | lib/big_brother/app.rb |