Class: Chimp::ChimpDaemon::DisplayServlet
- Inherits:
-
GenericServlet
- Object
- WEBrick::HTTPServlet::AbstractServlet
- GenericServlet
- Chimp::ChimpDaemon::DisplayServlet
- Defined in:
- lib/right_chimp/daemon/ChimpDaemon.rb
Overview
DisplayServlet
Instance Method Summary collapse
-
#do_GET(req, resp) ⇒ Object
do_GET.
Methods inherited from GenericServlet
#get_id, #get_job_uuid, #get_payload, #get_verb
Instance Method Details
#do_GET(req, resp) ⇒ Object
do_GET
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
# File 'lib/right_chimp/daemon/ChimpDaemon.rb', line 514 def do_GET(req, resp) # # First determine the path to the files to serve # if ENV['CHIMP_TEST'] != 'TRUE' template_path = File.join(Gem.dir, 'gems', 'right_chimp-' + VERSION, 'lib/right_chimp/templates') else template_path = 'lib/right_chimp/templates' end # # Check for static CSS files and serve them # if req.request_uri.path =~ /\.(css|js)$/ filename = req.request_uri.path.split('/').last resp.body = File.read(File.join(template_path, filename)) raise WEBrick::HTTPStatus::OK else # # Otherwise process ERB template # job_filter = self.get_verb(req) || "running" if not @template @template = ERB.new(File.read(File.join(template_path, "all_jobs.erb")), nil, ">") end queue = ChimpQueue.instance jobs = queue.get_jobs group_name = nil if job_filter == "group" group_name = req.request_uri.path.split('/')[-1] g = ChimpQueue[group_name.to_sym] jobs = g.get_jobs if g end count_jobs_running = queue.get_jobs_by_status(:running).size count_jobs_queued = queue.get_jobs_by_status(:none).size count_jobs_holding = queue.get_jobs_by_status(:holding).size count_jobs_failed = queue.get_jobs_by_status(:error).size count_jobs_done = queue.get_jobs_by_status(:done).size resp.body = @template.result(binding) raise WEBrick::HTTPStatus::OK end end |