Permalink
Browse files

adding a mechanism to quickly check the server log

  • Loading branch information...
jashkenas committed Mar 31, 2010
1 parent 0b44bc7 commit a8c25d75cf066f6bdd3e10a1e117a6dadfcb6b88
Showing with 25 additions and 2 deletions.
  1. +6 −1 lib/cloud_crowd/server.rb
  2. +7 −1 public/css/admin_console.css
  3. +11 −0 public/js/admin_console.js
  4. +1 −0 views/operations_center.erb
@@ -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.
#
# == 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.
# [put /work/:unit_id] Mark a finished WorkUnit as completed or failed, with results.
class Server < Sinatra::Base
@@ -48,6 +48,11 @@ class Server < Sinatra::Base
)
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 '/worker/:name' do
json WorkUnit.find_by_worker_name(params[:name]) || {}
@@ -91,11 +91,17 @@ body {
}
#sidebar_header {
position: absolute;
- width: 250px;
+ width: 283px;
top: 5px; left: 8px;
color: #404040;
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 .has_nodes {
display: block;
View
@@ -47,6 +47,7 @@ window.Console = {
this._disconnected = $('#disconnected');
$(window).bind('resize', Console.renderGraphs);
$('#nodes .worker').live('click', Console.getWorkerInfo);
+ $('#tail_log').bind('click', Console.tailLog);
$('#workers_legend').css({background : this.WORKERS_COLOR});
$('#nodes_legend').css({background : this.NODES_COLOR});
this.getStatus();
@@ -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.
countWorkers : function() {
var sum = 0;
@@ -48,6 +48,7 @@
<div id="sidebar_background"></div>
<div id="sidebar_bottom" class="sidebar_back"></div>
<div id="sidebar_header" class="small_caps">
+ <span id="tail_log">Check Server Log</span>
<span class="has_nodes"></span>
<span class="no_nodes">No Nodes Online&hellip;</span>
</div>

0 comments on commit a8c25d7

Please sign in to comment.