Module: Sinatra::RbbtRESTMonitor

Defined in:
lib/rbbt/rest/monitor.rb

Class Method Summary collapse

Class Method Details

.registered(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rbbt/rest/monitor.rb', line 5

def self.registered(base)
  base.module_eval do

    get '/locks' do
      lock_info = Rbbt.lock_info
      case @format
      when :json
        halt 200, lock_info.to_json
      else
        template_render('monitor/locks', {:lock_info => lock_info}, nil, :cache_type => :none)
      end
    end

    get '/jobs/:workflow' do
      workflow = params[:workflow]
      job_info = Rbbt.job_info(workflow)
      case @format
      when :json
        halt 200, job_info.to_json
      else
        template_render('monitor/jobs', {:workflow => workflow, :job_info => job_info}, nil, :cache_type => :none)
      end
    end

    get '/jobs/:workflow/:task' do
      workflow = params[:workflow]
      task = params[:task]
      job_info = Rbbt.job_info(workflow, task)
      case @format
      when :json
        halt 200, job_info.to_json
      else
        template_render('monitor/jobs', {:workflow => workflow, :job_info => job_info}, nil, :cache_type => :none)
      end
    end
  end
end