Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added the ability to open the god log for a watch in a new browser wi…

…ndow
  • Loading branch information...
commit 2a0f750aa8767c6a290120510ac944d722a90977 1 parent ea32857
Mathieu Ravaux authored
View
12 application.rb
@@ -19,6 +19,18 @@ def no_god
end
##
+ # Streams the god log to the client
+ ##
+ def log service
+ headers['Content-Type'] = 'text/plain'
+ headers['Cache-Control'] = 'no-cache'
+ headers['Pragma'] = 'no-cache'
+ @service = service
+ @log = GOD.running_log(service, Time.at(0))
+ display @log, :layout => false
+ end
+
+ ##
# Handles control commands for services
##
def control(command, service)
View
6 config/init.rb
@@ -18,6 +18,12 @@
Merb::Router.prepare do
match('/').to(:controller => 'prophet', :action =>'index').name(:root)
match('/no_god').to(:controller => 'prophet', :action => 'no_god').name(:no_god)
+ match('/log') do
+ with(:controller => 'prophet') do
+ match('').to(:action => 'log').name(:log)
+ match('/:service').to(:action => 'log')
+ end
+ end
match('/control') do
with(:controller => 'prophet') do
match('').to(:action => 'control').name(:control)
View
8 public/javascripts/main.js
@@ -21,5 +21,13 @@ $(document).ready(function() {
$('#controls').jqmShow();
});
});
+ $('.log_td a').each(function() {
+ $(this).bind("click", function(e) {
+ console.log('e: ', e);
+ window.open(e.target.href, "_blank", "toolbar=no,menubar=no,scrollbars=yes,resizable=yes");
+ return false;
+ });
+ });
+
});
View
2  views/prophet/index.html.haml
@@ -6,6 +6,7 @@
%th CPU
%th Memory
%th Status
+ %th Log
%tbody
- @watches.keys.each do |svc|
%tr{:id => svc, :class => 'service'}
@@ -14,6 +15,7 @@
%td= (@watches[svc].respond_to? "cpu_usage")? ("%.2f%%" % @watches[svc].cpu_usage) : "N/A"
%td= (@watches[svc].respond_to? "memory_usage")? (@watches[svc].memory_usage.to_s + "kb") : "N/A"
%td= @watches[svc].state
+ %td{:class => "log_td"}= (@watches[svc].log == "/dev/null") ? '-' : ( tag :a, @watches[svc].log, :target => "_blank", :href => "log/" + svc)
%div{:id => "controls", :class => "jqmWindow", :style => "display: none;"}
%h2#control_svc
View
7 views/prophet/log.html.haml
@@ -0,0 +1,7 @@
+!!! Strict
+%html
+ %head
+ %title= "God log for #{@service}"
+ %meta{ "http-equiv" => "refresh", :content => "1" }
+ %body
+ %pre= @log
Please sign in to comment.
Something went wrong with that request. Please try again.