From c4d56ab27b5ccbf3be6602742e66548aaaa019c1 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Wed, 31 Oct 2012 10:29:32 -0700 Subject: [PATCH] Tag sidekiq process with Rails app name [#463] --- Changes.md | 9 +++++++++ lib/sidekiq/cli.rb | 9 +++++++-- lib/sidekiq/manager.rb | 8 ++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Changes.md b/Changes.md index bba0f931..3988bd05 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,12 @@ +HEAD +----------- + +- Add -g option so the procline better identifies a Sidekiq process, defaults to File.basename(Rails.root). [#486] + + sidekiq 2.5.1 myapp [0 of 25 busy] + +- Add splay to retry time so groups of failed jobs don't fire all at once. [#483] + 2.5.1 ----------- diff --git a/lib/sidekiq/cli.rb b/lib/sidekiq/cli.rb index e16e86e3..3962154f 100644 --- a/lib/sidekiq/cli.rb +++ b/lib/sidekiq/cli.rb @@ -126,6 +126,7 @@ module Sidekiq require 'sidekiq/rails' require File.expand_path("#{options[:require]}/config/environment.rb") ::Rails.application.eager_load! + options[:tag] ||= File.basename(::Rails.root) else require options[:require] end @@ -164,7 +165,11 @@ module Sidekiq end o.on '-t', '--timeout NUM', "Shutdown timeout" do |arg| - opts[:timeout] = arg.to_i + opts[:timeout] = Integer(arg) + end + + o.on '-g', '--tag TAG', "Process tag for procline" do |arg| + opts[:tag] = arg end o.on '-r', '--require [PATH|DIR]', "Location of Rails application with workers or file to require" do |arg| @@ -172,7 +177,7 @@ module Sidekiq end o.on '-c', '--concurrency INT', "processor threads to use" do |arg| - opts[:concurrency] = arg.to_i + opts[:concurrency] = Integer(arg) end o.on '-P', '--pidfile PATH', "path to pidfile" do |arg| diff --git a/lib/sidekiq/manager.rb b/lib/sidekiq/manager.rb index c480b8d3..47781fe8 100644 --- a/lib/sidekiq/manager.rb +++ b/lib/sidekiq/manager.rb @@ -27,7 +27,7 @@ module Sidekiq @busy = [] @fetcher = Fetcher.new(current_actor, options[:queues], !!options[:strict]) @ready = @count.times.map { Processor.new_link(current_actor) } - procline + procline(options[:tag] ? "#{options[:tag]} " : '') end def stop(options={}) @@ -153,9 +153,9 @@ module Sidekiq @done end - def procline - $0 = "sidekiq #{Sidekiq::VERSION} [#{@busy.size} of #{@count} busy]#{stopped? ? ' stopping' : ''}" - after(5) { procline } + def procline(tag) + $0 = "sidekiq #{Sidekiq::VERSION} #{tag}[#{@busy.size} of #{@count} busy]#{stopped? ? ' stopping' : ''}" + after(5) { procline(tag) } end end end