Skip to content

Commit

Permalink
adding a mechanism to quickly check the server log
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Mar 31, 2010
1 parent 0b44bc7 commit a8c25d7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/cloud_crowd/server.rb
Expand Up @@ -14,7 +14,7 @@ module CloudCrowd
# [delete /jobs/:job_id] Clean up a Job when you're done downloading the results. Removes all intermediate files. # [delete /jobs/:job_id] Clean up a Job when you're done downloading the results. Removes all intermediate files.
# #
# == Internal Workers API # == Internal Workers API
# [puts /node/:host] Registers a new Node, making it available for processing. # [put /node/:host] Registers a new Node, making it available for processing.
# [delete /node/:host] Removes a Node from the registry, freeing up any WorkUnits that it had checked out. # [delete /node/:host] Removes a Node from the registry, freeing up any WorkUnits that it had checked out.
# [put /work/:unit_id] Mark a finished WorkUnit as completed or failed, with results. # [put /work/:unit_id] Mark a finished WorkUnit as completed or failed, with results.
class Server < Sinatra::Base class Server < Sinatra::Base
Expand Down Expand Up @@ -48,6 +48,11 @@ class Server < Sinatra::Base
) )
end end


# Get the last 100 lines of log messages.
get '/log' do
`tail -n 100 #{CloudCrowd.log_path('server.log')}`
end

# Get the JSON for what a worker is up to. # Get the JSON for what a worker is up to.
get '/worker/:name' do get '/worker/:name' do
json WorkUnit.find_by_worker_name(params[:name]) || {} json WorkUnit.find_by_worker_name(params[:name]) || {}
Expand Down
8 changes: 7 additions & 1 deletion public/css/admin_console.css
Expand Up @@ -91,11 +91,17 @@ body {
} }
#sidebar_header { #sidebar_header {
position: absolute; position: absolute;
width: 250px; width: 283px;
top: 5px; left: 8px; top: 5px; left: 8px;
color: #404040; color: #404040;
text-shadow: 0px 1px 1px #eee; text-shadow: 0px 1px 1px #eee;
} }
#tail_log {
text-transform: none;
text-decoration: underline;
cursor: pointer;
float: right;
}
#sidebar_header.no_nodes .no_nodes, #sidebar_header.no_nodes .no_nodes,
#sidebar_header .has_nodes { #sidebar_header .has_nodes {
display: block; display: block;
Expand Down
11 changes: 11 additions & 0 deletions public/js/admin_console.js
Expand Up @@ -47,6 +47,7 @@ window.Console = {
this._disconnected = $('#disconnected'); this._disconnected = $('#disconnected');
$(window).bind('resize', Console.renderGraphs); $(window).bind('resize', Console.renderGraphs);
$('#nodes .worker').live('click', Console.getWorkerInfo); $('#nodes .worker').live('click', Console.getWorkerInfo);
$('#tail_log').bind('click', Console.tailLog);
$('#workers_legend').css({background : this.WORKERS_COLOR}); $('#workers_legend').css({background : this.WORKERS_COLOR});
$('#nodes_legend').css({background : this.NODES_COLOR}); $('#nodes_legend').css({background : this.NODES_COLOR});
this.getStatus(); this.getStatus();
Expand All @@ -73,6 +74,16 @@ window.Console = {
}}); }});
}, },


// Fetch the last 100 lines of log from the server.
tailLog : function() {
$.ajax({url : 'log', success : function(resp) {
var win = window.open('');
win.document.open();
win.document.write('<pre>' + resp + '</pre>');
win.document.close();
}});
},

// Count the total number of workers in the current list of nodes. // Count the total number of workers in the current list of nodes.
countWorkers : function() { countWorkers : function() {
var sum = 0; var sum = 0;
Expand Down
1 change: 1 addition & 0 deletions views/operations_center.erb
Expand Up @@ -48,6 +48,7 @@
<div id="sidebar_background"></div> <div id="sidebar_background"></div>
<div id="sidebar_bottom" class="sidebar_back"></div> <div id="sidebar_bottom" class="sidebar_back"></div>
<div id="sidebar_header" class="small_caps"> <div id="sidebar_header" class="small_caps">
<span id="tail_log">Check Server Log</span>
<span class="has_nodes"></span> <span class="has_nodes"></span>
<span class="no_nodes">No Nodes Online&hellip;</span> <span class="no_nodes">No Nodes Online&hellip;</span>
</div> </div>
Expand Down

0 comments on commit a8c25d7

Please sign in to comment.