Sha256: 50cf1313b03c39cfedeb83e0451f9b48c7bec0909dbfa855fd4be1d7869ba9c1
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
module BigBrother class App < Sinatra::Base register Sinatra::Synchrony set :raise_errors, false get "/" do [200, <<-CONTENT] Big Brother: #{BigBrother::VERSION} Running: #{BigBrother.clusters.running.map { |cluster| "+ #{cluster} - CombinedWeight: #{cluster.combined_weight}\n" }.join} Stopped: #{BigBrother.clusters.stopped.map { |cluster| "- #{cluster}\n" }.join} CONTENT 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?}\nCombinedWeight: #{@cluster.combined_weight}\n"] 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
big_brother-0.6.2 | lib/big_brother/app.rb |
big_brother-0.6.1 | lib/big_brother/app.rb |
big_brother-0.6.0 | lib/big_brother/app.rb |