lib/cloud_crowd/app.rb in documentcloud-cloud-crowd-0.0.1 vs lib/cloud_crowd/app.rb in documentcloud-cloud-crowd-0.0.2
- old
+ new
@@ -1,14 +1,26 @@
+require 'erb'
+require 'sinatra'
+require 'cloud_crowd/models'
+require 'cloud_crowd/helpers'
+
module CloudCrowd
class App < Sinatra::Default
# static serves files from /public, methodoverride allows the _method param.
enable :static, :methodoverride
+ set :root, CloudCrowd::ROOT
+ set :authorization_realm, "CloudCrowd"
+
helpers CloudCrowd::Helpers
+ before do
+ login_required if CloudCrowd.config[:use_http_authentication]
+ end
+
# Start a new job. Accepts a JSON representation of the job-to-be.
post '/jobs' do
Job.create_from_request(JSON.parse(params[:json])).to_json
end
@@ -45,9 +57,15 @@
when 'succeeded' then current_work_unit.finish(params[:output], params[:time])
when 'failed' then current_work_unit.fail(params[:output], params[:time])
else return error(500, "Completing a work unit must specify status.")
end
return status(204) && ''
+ end
+
+ # To monitor the central server with Monit, God, Nagios, or another
+ # monitoring tool, you can hit /heartbeat to check.
+ get '/heartbeat' do
+ "buh-bump"
end
end
end
\ No newline at end of file