Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

a basic controller for monitoring backgroundrb workers

  • Loading branch information...
commit 17b41722df688a74708149bc8359d870b401e348 1 parent 336bd72
@gnufied authored
View
7 app/controller/backgroundrb_status_controller.rb
@@ -0,0 +1,7 @@
+require "application"
+class BackgroundrbStatusController < ApplicationController
+ def index
+ status = MiddleMan.all_worker_info
+ render :text => status
+ end
+end
View
5 init.rb
@@ -1,2 +1,7 @@
# Include hook code here
+%w{ controller }.each do |code_dir|
+ $:.unshift File.join(directory,"app",code_dir)
+end
+
require 'backgroundrb'
+require "backgroundrb_status_controller"
View
8 lib/backgroundrb/bdrb_cluster_connection.rb
@@ -47,6 +47,14 @@ def worker(worker_name,worker_key = nil)
chosen.worker(worker_name,worker_key)
end
+ def all_worker_info
+ info_data = {}
+ @backend_connections.each do |t_connection|
+ info_data[t_connection.server_info] = t_connection.all_worker_info
+ end
+ return info_data
+ end
+
def new_worker options = {}
chosen = choose_server
chosen.new_worker(options)
View
4 lib/backgroundrb/bdrb_connection.rb
@@ -51,6 +51,10 @@ def write_data data
end
end
+ def server_info
+ "#{server_ip}:#{server_port}"
+ end
+
def flush_in_loop(data)
t_length = data.length
loop do
Please sign in to comment.
Something went wrong with that request. Please try again.