diff --git a/code/adminoper.rb b/code/adminoper.rb index 7b194be..b0ceaf5 100644 --- a/code/adminoper.rb +++ b/code/adminoper.rb @@ -1,8 +1,7 @@ module RQ class AdminOper - attr_accessor :admin_status - attr_accessor :oper_status + attr_accessor :status def initialize(pathname) @pathname = pathname @@ -13,18 +12,17 @@ def initialize(pathname) @down_name = @dirname + "/" + @filename + ".down" @pause_name = @dirname + "/" + @filename + ".pause" - @admin_status = "UNKNOWN" - @oper_status = "UNKNOWN" + @status = "UNKNOWN" @daemon_status = "UP" end def update! if File.exists?(@down_name) - @admin_status = @oper_status = "DOWN" + @status = "DOWN" elsif File.exists?(@pause_name) - @admin_status = @oper_status = "PAUSE" + @status = "PAUSE" else - @admin_status = @oper_status = "UP" + @status = "UP" end update_status end @@ -36,14 +34,11 @@ def set_daemon_status(stat) update_status end + private + def update_status - if @daemon_status == "UP" - @oper_status = @admin_status - else - @oper_status = @daemon_status - end + @status = @daemon_status if @daemon_status != "UP" end - private :update_status end end diff --git a/code/main.rb b/code/main.rb index 50dee01..1489956 100644 --- a/code/main.rb +++ b/code/main.rb @@ -214,7 +214,7 @@ def flash(type, msg) throw :halt, [400, "400 - Invalid method param"] end - if result == [ "fail", "oper_status: DOWN"] + if result == [ "fail", "status: DOWN"] throw :halt, [503, "503 - Service Unavailable - Operationally Down"] end @@ -250,7 +250,7 @@ def flash(type, msg) end flash :notice, "Successfully #{action}d queue #{params[:name]}" - redirect back + redirect params[:back] end post '/q/:name/restart' do @@ -264,7 +264,7 @@ def flash(type, msg) end flash :notice, "Successfully restarted queue #{params[:name]}" - redirect back + redirect params[:back] end get '/q/:name/config.json' do diff --git a/code/public/css/rq.css b/code/public/css/rq.css index 200315b..302579a 100644 --- a/code/public/css/rq.css +++ b/code/public/css/rq.css @@ -116,7 +116,6 @@ h1 {font-size: 2.5em; margin-top: 0; margin-bottom: 2px; font-weight: bold; #queue-status, #message-actions { float: right; - width: 300px; text-align: right } .right {text-align: right} @@ -182,12 +181,12 @@ form .note { font-style: italic; } -form.inline { +form.inrow { padding: 0; margin: 0; } -form.inline button { +form.inrow button { width: 5em; } diff --git a/code/queue.rb b/code/queue.rb index 6d57581..a9f7e41 100644 --- a/code/queue.rb +++ b/code/queue.rb @@ -260,18 +260,18 @@ def run_queue_script!(msg) script_path = Pathname.new(@config.script).realpath.to_s rescue @config.script if (!File.executable?(script_path) rescue false) log("ERROR - QUEUE SCRIPT - not there or runnable #{script_path}") - if @status.oper_status != 'SCRIPTERROR' + if @status.status != 'SCRIPTERROR' @status.set_daemon_status('SCRIPTERROR') log("SCRIPTERROR - DAEMON STATUS is set to SCRIPTERROR") - log("OPER STATUS is now: #{@status.oper_status}") + log("OPER STATUS is now: #{@status.status}") end return end - if @status.oper_status == 'SCRIPTERROR' + if @status.status == 'SCRIPTERROR' @status.set_daemon_status('UP') log("SCRIPTERROR FIXED - DAEMON STATUS is set to UP") - log("OPER STATUS is now: #{@status.oper_status}") + log("OPER STATUS is now: #{@status.status}") end #log("0 child process prep step for runnable #{script_path}") @@ -1225,7 +1225,7 @@ def run_scheduler! @status.update! # This could be DOWN, PAUSE, SCRIPTERROR - return unless @status.oper_status == 'UP' + return unless @status.status == 'UP' # Are we arleady running max workers active_count = @run.inject(0) do |acc, o| @@ -1513,7 +1513,7 @@ def handle_request(sock) when 'status' @status.update! - resp = [ @status.admin_status, @status.oper_status ].to_json + resp = [ @status.status ].to_json send_packet(sock, resp) return @@ -1524,10 +1524,10 @@ def handle_request(sock) return end - # IF queue is admin_status DOWN, no need to respond to any of the + # IF queue status is DOWN, no need to respond to any of the # following messages (Note: there are other states, this is a hard DOWN) - if @status.admin_status == 'DOWN' - resp = [ "fail", "oper_status: DOWN"].to_json + if @status.status == 'DOWN' + resp = [ "fail", "status: DOWN"].to_json send_packet(sock, resp) return end diff --git a/code/queueclient.rb b/code/queueclient.rb index 8bd02d8..4440893 100644 --- a/code/queueclient.rb +++ b/code/queueclient.rb @@ -43,7 +43,6 @@ def read_pid end PROTOCOL_MESSAGES = %w{ - status shutdown num_messages config @@ -71,5 +70,9 @@ def uptime send_recv('uptime').first end + def status + send_recv('status').first + end + end end diff --git a/code/views/_main_queue_form.erb b/code/views/_main_queue_form.erb new file mode 100644 index 0000000..f856367 --- /dev/null +++ b/code/views/_main_queue_form.erb @@ -0,0 +1,17 @@ +
+ diff --git a/code/views/_main_queue_row.erb b/code/views/_main_queue_row.erb index c75132e..7406999 100644 --- a/code/views/_main_queue_row.erb +++ b/code/views/_main_queue_row.erb @@ -3,9 +3,9 @@ <% begin qc = get_queueclient(name) raise unless qc.running? - admin_stat, oper_stat = qc.status + status = qc.status -%> -<% if admin_stat != 'DOWN' -%> +<% if status != 'DOWN' -%><%= msgs_labels.zip(qc.num_messages.values_at(*msgs_labels)).map{|ab| "#{ab[0]}:#{ab[1].to_s.ljust(4)} "}.join %>
"><%= admin_status %>:"><%= oper_status %> + "><%= status %> <%= qc.ping %> <%= qc.read_pid %> - up for <%= qc.uptime %> seconds
+ running for <%= qc.uptime %> seconds +<%= erb :_main_queue_form, :locals => {:status => status, :url => url, :name => qc.name } %> <% else %> -Status: queue is COMPLETELY DOWN
+ Status: queue is COMPLETELY DOWN <% end %>