diff --git a/lib/cloud_crowd/server.rb b/lib/cloud_crowd/server.rb index d3fefc8..2615d5c 100644 --- a/lib/cloud_crowd/server.rb +++ b/lib/cloud_crowd/server.rb @@ -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]) || {} diff --git a/public/css/admin_console.css b/public/css/admin_console.css index 52bed46..57b43b4 100644 --- a/public/css/admin_console.css +++ b/public/css/admin_console.css @@ -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; diff --git a/public/js/admin_console.js b/public/js/admin_console.js index 6d7d535..73e8375 100644 --- a/public/js/admin_console.js +++ b/public/js/admin_console.js @@ -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('
' + resp + '
'); + win.document.close(); + }}); + }, + // Count the total number of workers in the current list of nodes. countWorkers : function() { var sum = 0; diff --git a/views/operations_center.erb b/views/operations_center.erb index 03d30db..ec6ee6a 100644 --- a/views/operations_center.erb +++ b/views/operations_center.erb @@ -48,6 +48,7 @@