diff --git a/Gemfile.lock b/Gemfile.lock index be60d74df1..23413784ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,187 +10,213 @@ PATH GEM remote: https://rubygems.org/ specs: - actioncable (6.0.2.1) - actionpack (= 6.0.2.1) + actioncable (7.0.4.3) + actionpack (= 7.0.4.3) + activesupport (= 7.0.4.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.2.1) - actionpack (= 6.0.2.1) - activejob (= 6.0.2.1) - activerecord (= 6.0.2.1) - activestorage (= 6.0.2.1) - activesupport (= 6.0.2.1) + actionmailbox (7.0.4.3) + actionpack (= 7.0.4.3) + activejob (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) mail (>= 2.7.1) - actionmailer (6.0.2.1) - actionpack (= 6.0.2.1) - actionview (= 6.0.2.1) - activejob (= 6.0.2.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.4.3) + actionpack (= 7.0.4.3) + actionview (= 7.0.4.3) + activejob (= 7.0.4.3) + activesupport (= 7.0.4.3) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.0.2.1) - actionview (= 6.0.2.1) - activesupport (= 6.0.2.1) - rack (~> 2.0, >= 2.0.8) + actionpack (7.0.4.3) + actionview (= 7.0.4.3) + activesupport (= 7.0.4.3) + rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.2.1) - actionpack (= 6.0.2.1) - activerecord (= 6.0.2.1) - activestorage (= 6.0.2.1) - activesupport (= 6.0.2.1) + actiontext (7.0.4.3) + actionpack (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.0.2.1) - activesupport (= 6.0.2.1) + actionview (7.0.4.3) + activesupport (= 7.0.4.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.0.2.1) - activesupport (= 6.0.2.1) + activejob (7.0.4.3) + activesupport (= 7.0.4.3) globalid (>= 0.3.6) - activemodel (6.0.2.1) - activesupport (= 6.0.2.1) - activerecord (6.0.2.1) - activemodel (= 6.0.2.1) - activesupport (= 6.0.2.1) - activerecord-jdbc-adapter (60.1-java) - activerecord (~> 6.0.0) - activerecord-jdbcsqlite3-adapter (60.1-java) - activerecord-jdbc-adapter (= 60.1) - jdbc-sqlite3 (~> 3.8, < 3.30) - activestorage (6.0.2.1) - actionpack (= 6.0.2.1) - activejob (= 6.0.2.1) - activerecord (= 6.0.2.1) - marcel (~> 0.3.1) - activesupport (6.0.2.1) + activemodel (7.0.4.3) + activesupport (= 7.0.4.3) + activerecord (7.0.4.3) + activemodel (= 7.0.4.3) + activesupport (= 7.0.4.3) + activestorage (7.0.4.3) + actionpack (= 7.0.4.3) + activejob (= 7.0.4.3) + activerecord (= 7.0.4.3) + activesupport (= 7.0.4.3) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (7.0.4.3) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2) - ast (2.4.0) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + ast (2.4.2) builder (3.2.4) - byebug (11.1.1) - coderay (1.1.2) - concurrent-ruby (1.1.6) - connection_pool (2.2.2) + byebug (11.1.3) + coderay (1.1.3) + concurrent-ruby (1.2.2) + connection_pool (2.4.1) crass (1.0.6) - docile (1.3.2) - erubi (1.9.0) - globalid (0.4.2) - activesupport (>= 4.2.0) + date (3.3.3) + docile (1.4.0) + erubi (1.12.0) + globalid (1.1.0) + activesupport (>= 5.0) hiredis (0.6.3) - hiredis (0.6.3-java) - i18n (1.8.2) + i18n (1.13.0) concurrent-ruby (~> 1.0) - jaro_winkler (1.5.4) - jaro_winkler (1.5.4-java) - jdbc-sqlite3 (3.28.0) - loofah (2.4.0) + json (2.6.3) + language_server-protocol (3.17.0.3) + lint_roller (1.0.0) + loofah (2.21.3) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.7.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (0.3.3) - mimemagic (~> 0.3.2) - method_source (0.9.2) - mimemagic (0.3.4) - mini_mime (1.0.2) - mini_portile2 (2.4.0) - minitest (5.14.0) - nio4r (2.5.2) - nio4r (2.5.2-java) - nokogiri (1.10.8) - mini_portile2 (~> 2.4.0) - nokogiri (1.10.8-java) - parallel (1.19.1) - parser (2.7.0.4) - ast (~> 2.4.0) - pry (0.12.2) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - pry-byebug (3.8.0) + net-imap + net-pop + net-smtp + marcel (1.0.2) + method_source (1.0.0) + mini_mime (1.1.2) + mini_portile2 (2.8.2) + minitest (5.18.0) + net-imap (0.3.4) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.3.3) + net-protocol + nio4r (2.5.9) + nokogiri (1.15.1) + mini_portile2 (~> 2.8.2) + racc (~> 1.4) + parallel (1.23.0) + parser (3.2.2.1) + ast (~> 2.4.1) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.10.1) byebug (~> 11.0) - pry (~> 0.10) - rack (2.2.2) - rack-protection (2.0.8.1) + pry (>= 0.13, < 0.15) + racc (1.6.2) + rack (2.2.7) + rack-protection (3.0.6) rack - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (6.0.2.1) - actioncable (= 6.0.2.1) - actionmailbox (= 6.0.2.1) - actionmailer (= 6.0.2.1) - actionpack (= 6.0.2.1) - actiontext (= 6.0.2.1) - actionview (= 6.0.2.1) - activejob (= 6.0.2.1) - activemodel (= 6.0.2.1) - activerecord (= 6.0.2.1) - activestorage (= 6.0.2.1) - activesupport (= 6.0.2.1) - bundler (>= 1.3.0) - railties (= 6.0.2.1) - sprockets-rails (>= 2.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rails (7.0.4.3) + actioncable (= 7.0.4.3) + actionmailbox (= 7.0.4.3) + actionmailer (= 7.0.4.3) + actionpack (= 7.0.4.3) + actiontext (= 7.0.4.3) + actionview (= 7.0.4.3) + activejob (= 7.0.4.3) + activemodel (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) + bundler (>= 1.15.0) + railties (= 7.0.4.3) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) - loofah (~> 2.3) - railties (6.0.2.1) - actionpack (= 6.0.2.1) - activesupport (= 6.0.2.1) + rails-html-sanitizer (1.5.0) + loofah (~> 2.19, >= 2.19.1) + railties (7.0.4.3) + actionpack (= 7.0.4.3) + activesupport (= 7.0.4.3) method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) - rainbow (3.0.0) - rake (13.0.1) - redis (4.1.3) - redis-namespace (1.7.0) - redis (>= 3.0.4) - rubocop (0.79.0) - jaro_winkler (~> 1.5.1) + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) + rainbow (3.1.1) + rake (13.0.6) + redis (5.0.6) + redis-client (>= 0.9.0) + redis-client (0.14.1) + connection_pool + redis-namespace (1.10.0) + redis (>= 4) + regexp_parser (2.8.0) + rexml (3.2.5) + rubocop (1.50.2) + json (~> 2.3) parallel (~> 1.10) - parser (>= 2.7.0.1) + parser (>= 3.2.0.0) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) - rubocop-performance (1.5.2) - rubocop (>= 0.71.0) - ruby-progressbar (1.10.1) - simplecov (0.18.2) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.28.1) + parser (>= 3.2.1.0) + rubocop-performance (1.16.0) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + ruby-progressbar (1.13.0) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) - simplecov-html (0.12.0) - sprockets (4.0.0) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + sqlite3 (1.6.3) + mini_portile2 (~> 2.8.0) + standard (1.28.2) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50.2) + standard-custom (~> 1.0.0) + standard-performance (~> 1.0.1) + standard-custom (1.0.0) + lint_roller (~> 1.0) + standard-performance (1.0.1) + lint_roller (~> 1.0) + rubocop-performance (~> 1.16.0) + thor (1.2.2) + timeout (0.3.2) + toxiproxy (2.0.2) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) - sprockets (>= 3.0.0) - sqlite3 (1.4.2) - standard (0.2.1) - rubocop (~> 0.79.0) - rubocop-performance (~> 1.5.1) - thor (1.0.1) - thread_safe (0.3.6) - thread_safe (0.3.6-java) - toxiproxy (1.0.3) - tzinfo (1.2.6) - thread_safe (~> 0.1) - unicode-display_width (1.6.1) - websocket-driver (0.7.1) - websocket-extensions (>= 0.1.0) - websocket-driver (0.7.1-java) + unicode-display_width (2.4.2) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.4) - zeitwerk (2.2.2) + websocket-extensions (0.1.5) + zeitwerk (2.6.8) PLATFORMS - java ruby DEPENDENCIES @@ -206,3 +232,6 @@ DEPENDENCIES sqlite3 standard toxiproxy + +BUNDLED WITH + 2.2.30 diff --git a/lib/sidekiq/web/application.rb b/lib/sidekiq/web/application.rb index da787dce99..b4528d3d47 100644 --- a/lib/sidekiq/web/application.rb +++ b/lib/sidekiq/web/application.rb @@ -88,19 +88,28 @@ def self.set(key, val) erb(:queue) end - - post "/queues/:name" do + + post '/queues/:name' do queue = Sidekiq::Queue.new(route_params[:name]) - if Sidekiq.pro? && params["pause"] + unless Sidekiq.pro? + queue.clear + redirect "#{root_path}queues" + end + + if params['pause'] queue.pause! - elsif Sidekiq.pro? && params["unpause"] + elsif params['unpause'] queue.unpause! - else + elsif params['set_non_work_hour'] + queue.set_non_work_hour_only! + elsif params['unset_non_work_hour'] + queue.unset_non_work_hour_only! + elsif params['delete'] queue.clear end - redirect "#{root_path}queues" + redirect "#{root_path}queues/#{route_params[:name]}" end post "/queues/:name/delete" do diff --git a/web/locales/en.yml b/web/locales/en.yml index 161968e897..f13503c1b2 100644 --- a/web/locales/en.yml +++ b/web/locales/en.yml @@ -26,7 +26,9 @@ en: # <---- change this to your locale code Delete: Delete AddToQueue: Add to queue AreYouSureDeleteJob: Are you sure you want to delete this job? - AreYouSureDeleteQueue: Are you sure you want to delete the %{queue} queue? + AreYouSureDeleteQueue: Are you sure you want to delete the %{queue} queue? This will delete all jobs within the queue, it will reappear if you push more jobs to it in the future. + AreYouSureNonWorkHourQueue: Are you sure? This will pause the %{queue} queue and will execute the jobs only during non-work hours! + AreYouSureUnpauseNonWorkHourQueue: "Running an intensive job during work-hours may have real production consequence on performance. It is not uncommon for such jobs to hammer our database and slow down the website. Please seek approval from Ray or the #squad-platform before you do this." Queues: Queues Size: Size Actions: Actions @@ -81,3 +83,5 @@ en: # <---- change this to your locale code Latency: Latency Pause: Pause Unpause: Unpause + StartExecution: Run all hours + PauseTillNonWorkHours: Run non-work hours diff --git a/web/views/_poll_link.erb b/web/views/_poll_link.erb index d6aba17986..1985b2be38 100644 --- a/web/views/_poll_link.erb +++ b/web/views/_poll_link.erb @@ -1,7 +1,7 @@ -<% if current_path != '' %> + diff --git a/web/views/queue.erb b/web/views/queue.erb index a79f88989a..ba2781248d 100644 --- a/web/views/queue.erb +++ b/web/views/queue.erb @@ -1,11 +1,39 @@
+

<%= t('CurrentMessagesInQueue', :queue => h(@name)) %> - <% if @queue.paused? %> + <% if (@paused = @queue.paused?) %> <%= t('Paused') %> <% end %> <%= number_with_delimiter(@total_size) %> +
+ <%= csrf_tag %> + <% if @queue.is_non_work_hour_only? %> + + <% else %> + + <% end %> + <% unless @queue.is_non_work_hour_only? %> + <% if @queue.paused? %> + + <% else %> + + <% end %> + <% end %> + +

diff --git a/web/views/queues.erb b/web/views/queues.erb index f4dde49d25..1f03d013f8 100644 --- a/web/views/queues.erb +++ b/web/views/queues.erb @@ -1,38 +1,61 @@

<%= t('Queues') %>

-
+ + <% @count = (params['per_page'] || 20).to_i %> + <% @current_page = (params['page'] || 1).to_i %> + <% @total_size = @queues.size %> - + - <% @queues.each do |queue| %> + <% @queues.sort_by(&:name).each_slice(@count).to_a[@current_page - 1].each do |queue| %> - + <% end %>
<%= t('Queue') %> <%= t('Size') %> <%= t('Latency') %><%= t('Actions') %><%= t('Actions') %>
<%= h queue.name %> <% if queue.paused? %> - <%= t('Paused') %> + <%= t('Paused') %> + <% end %> + <% if queue.is_non_work_hour_only? %> + Non-work hours only <% end %> <%= number_with_delimiter(queue.size) %> <% queue_latency = queue.latency %><%= number_with_delimiter(queue_latency.round(2)) %><%= (queue_latency < 60) ? '' : " (#{relative_time(Time.at(Time.now.to_f - queue_latency))})" %> + <% queue_latency = queue.latency %><%= number_with_delimiter(queue_latency.round(2)) %><%= (queue_latency < 60) ? '' : " (#{relative_time(Time.at(Time.now.to_f - queue_latency))})" %> -
+ <%= csrf_tag %> - - - <% if Sidekiq.pro? %> + <% if queue.is_non_work_hour_only? %> + + <% else %> + + <% end %> + <% unless queue.is_non_work_hour_only? %> <% if queue.paused? %> - + <% else %> - + <% end %> <% end %> +
+ <%= erb :_paging, locals: { url: "#{root_path}queues" } %>