sidekiq-web_custom 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.circleci/config.yml +109 -0
- data/.gitignore +18 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Dockerfile +18 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +182 -0
- data/LICENSE.txt +21 -0
- data/Makefile +40 -0
- data/README.md +92 -0
- data/Rakefile +8 -0
- data/bin/all_workers +69 -0
- data/bin/bundle +114 -0
- data/bin/publish +40 -0
- data/bin/publish_git +38 -0
- data/bin/publish_ruby_gems +22 -0
- data/bin/rails +18 -0
- data/bin/sidekiq +29 -0
- data/bin/sidekiqmon +29 -0
- data/docker-compose.yml +43 -0
- data/dummy_rails/.rspec +4 -0
- data/dummy_rails/app/assets/config/manifest.js +0 -0
- data/dummy_rails/app/controllers/application_controller.rb +2 -0
- data/dummy_rails/app/helpers/application_helper.rb +2 -0
- data/dummy_rails/app/views/layouts/application.html.erb +15 -0
- data/dummy_rails/app/views/layouts/mailer.html.erb +13 -0
- data/dummy_rails/app/workers/exclude_hard_worker.rb +15 -0
- data/dummy_rails/app/workers/exclude_lazy_worker.rb +11 -0
- data/dummy_rails/app/workers/exclude_random_raise_worker.rb +11 -0
- data/dummy_rails/app/workers/hard_worker.rb +15 -0
- data/dummy_rails/app/workers/lazy_worker.rb +10 -0
- data/dummy_rails/app/workers/random_raise_worker.rb +12 -0
- data/dummy_rails/app/workers/taco_worker.rb +12 -0
- data/dummy_rails/app/workers/tostada_worker.rb +11 -0
- data/dummy_rails/bin/rspec +5 -0
- data/dummy_rails/config.ru +5 -0
- data/dummy_rails/config/application.rb +20 -0
- data/dummy_rails/config/boot.rb +5 -0
- data/dummy_rails/config/environment.rb +5 -0
- data/dummy_rails/config/environments/development.rb +52 -0
- data/dummy_rails/config/environments/production.rb +88 -0
- data/dummy_rails/config/environments/test.rb +40 -0
- data/dummy_rails/config/initializers/assets.rb +14 -0
- data/dummy_rails/config/initializers/cookies_serializer.rb +5 -0
- data/dummy_rails/config/initializers/filter_parameter_logging.rb +4 -0
- data/dummy_rails/config/initializers/sidekiq-web_custom.rb +3 -0
- data/dummy_rails/config/initializers/wrap_parameters.rb +14 -0
- data/dummy_rails/config/locales/en.yml +33 -0
- data/dummy_rails/config/puma.rb +37 -0
- data/dummy_rails/config/routes.rb +5 -0
- data/dummy_rails/config/secrets.yml +5 -0
- data/dummy_rails/config/spring.rb +5 -0
- data/dummy_rails/config/storage.yml +34 -0
- data/dummy_rails/package.json +5 -0
- data/dummy_rails/spec/spec_helper.rb +50 -0
- data/lib/load_random_workers.rb +25 -0
- data/lib/sidekiq/views/actions/queues/delete.erb +12 -0
- data/lib/sidekiq/views/actions/queues/drain_queue.erb +4 -0
- data/lib/sidekiq/views/actions/queues/pause.erb +13 -0
- data/lib/sidekiq/views/actions/retries/delete.erb +5 -0
- data/lib/sidekiq/views/actions/retries/execute.erb +7 -0
- data/lib/sidekiq/views/actions/scheduled/delete.erb +5 -0
- data/lib/sidekiq/views/actions/scheduled/execute.erb +7 -0
- data/lib/sidekiq/views/queues.erb +64 -0
- data/lib/sidekiq/views/retries.erb +123 -0
- data/lib/sidekiq/views/scheduled.erb +97 -0
- data/lib/sidekiq/web_custom.rb +95 -0
- data/lib/sidekiq/web_custom/configuration.rb +112 -0
- data/lib/sidekiq/web_custom/job.rb +11 -0
- data/lib/sidekiq/web_custom/processor.rb +82 -0
- data/lib/sidekiq/web_custom/queue.rb +12 -0
- data/lib/sidekiq/web_custom/timeout.rb +64 -0
- data/lib/sidekiq/web_custom/version.rb +14 -0
- data/lib/sidekiq/web_custom/web_action.rb +38 -0
- data/lib/sidekiq/web_custom/web_app.rb +46 -0
- data/sidekiq-web_custom.gemspec +37 -0
- metadata +151 -0
data/bin/rails
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails gems
|
3
|
+
# installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_ROOT = File.expand_path('..', __dir__)
|
6
|
+
ENGINE_PATH = File.expand_path('../lib/sidekiq/web_custom.rb', __dir__)
|
7
|
+
APP_PATH = File.expand_path('../dummy_rails/config/application', __dir__)
|
8
|
+
|
9
|
+
# Set up gems listed in the Gemfile.
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
11
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
12
|
+
|
13
|
+
require 'action_controller/railtie'
|
14
|
+
require 'action_mailer/railtie'
|
15
|
+
require 'sprockets/railtie'
|
16
|
+
require 'rails/test_unit/railtie'
|
17
|
+
|
18
|
+
require 'rails/engine/commands'
|
data/bin/sidekiq
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'sidekiq' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("sidekiq", "sidekiq")
|
data/bin/sidekiqmon
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'sidekiqmon' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("sidekiq", "sidekiqmon")
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
version: '3'
|
2
|
+
|
3
|
+
services:
|
4
|
+
redis:
|
5
|
+
image: redis
|
6
|
+
expose:
|
7
|
+
- 6379
|
8
|
+
app:
|
9
|
+
command: bin/rails s -p 1111 -e development -b '0.0.0.0'
|
10
|
+
stdin_open: true
|
11
|
+
tty: true
|
12
|
+
build:
|
13
|
+
context: .
|
14
|
+
dockerfile: ./Dockerfile
|
15
|
+
ports:
|
16
|
+
- "1111:1111"
|
17
|
+
environment:
|
18
|
+
REDIS_URL: redis://redis
|
19
|
+
volumes:
|
20
|
+
- .:/gem
|
21
|
+
- bundle-cache:/usr/local/bundle
|
22
|
+
- ..:/local
|
23
|
+
links:
|
24
|
+
- redis
|
25
|
+
- sidekiq
|
26
|
+
sidekiq:
|
27
|
+
command: bin/all_workers
|
28
|
+
stdin_open: true
|
29
|
+
tty: true
|
30
|
+
build:
|
31
|
+
context: .
|
32
|
+
dockerfile: ./Dockerfile
|
33
|
+
environment:
|
34
|
+
RAILS_ENV: development
|
35
|
+
REDIS_URL: redis://redis
|
36
|
+
volumes:
|
37
|
+
- .:/gem
|
38
|
+
- bundle-cache:/usr/local/bundle
|
39
|
+
- ..:/local
|
40
|
+
links:
|
41
|
+
- redis
|
42
|
+
volumes:
|
43
|
+
bundle-cache:
|
data/dummy_rails/.rspec
ADDED
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>DummyRails</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= stylesheet_link_tag 'application', media: 'all' %>
|
9
|
+
<%= javascript_include_tag 'application' %>
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<%= yield %>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ExcludeHardWorker
|
4
|
+
include Sidekiq::Worker
|
5
|
+
|
6
|
+
sidekiq_options queue: File.basename(__FILE__,'.*').downcase
|
7
|
+
|
8
|
+
DEFAULT_SLEEP = 10.seconds
|
9
|
+
|
10
|
+
def perform(sleep_seconds = DEFAULT_SLEEP)
|
11
|
+
Sidekiq.logger.info "I am a harrrddddd worker. I go nap for #{sleep_seconds} seconds"
|
12
|
+
sleep(sleep_seconds)
|
13
|
+
Sidekiq.logger.info "Good nap"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ExcludeRandomRaiseWorker
|
4
|
+
include Sidekiq::Worker
|
5
|
+
|
6
|
+
sidekiq_options queue: File.basename(__FILE__,'.*').downcase
|
7
|
+
|
8
|
+
def perform(threshold = 0.5)
|
9
|
+
raise StandardError, "Yikes. Unlucky. I decided to raise" if rand > threshold.to_f
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class HardWorker
|
4
|
+
include Sidekiq::Worker
|
5
|
+
|
6
|
+
sidekiq_options queue: File.basename(__FILE__,'.*').downcase
|
7
|
+
|
8
|
+
DEFAULT_SLEEP = 10
|
9
|
+
|
10
|
+
def perform(sleep_seconds = DEFAULT_SLEEP)
|
11
|
+
Sidekiq.logger.info "Night Night for #{sleep_seconds}"
|
12
|
+
sleep(sleep_seconds)
|
13
|
+
Sidekiq.logger.info 'Back alive'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class RandomRaiseWorker
|
4
|
+
include Sidekiq::Worker
|
5
|
+
|
6
|
+
sidekiq_options queue: File.basename(__FILE__,'.*').downcase
|
7
|
+
|
8
|
+
def perform(raise_sample = 0.5)
|
9
|
+
raise_sample = params[:raise_sample] || 0.5
|
10
|
+
raise ArgumentError, "For no good Reason I raised with %#{raise_sample}" if rand > raise_sample
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'boot'
|
2
|
+
|
3
|
+
require 'action_controller/railtie'
|
4
|
+
require 'action_mailer/railtie'
|
5
|
+
require 'sprockets/railtie'
|
6
|
+
require 'rails/test_unit/railtie'
|
7
|
+
|
8
|
+
require 'byebug'
|
9
|
+
Bundler.require(*Rails.groups)
|
10
|
+
require 'sidekiq/web_custom'
|
11
|
+
|
12
|
+
module DummyRails
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration can go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded after loading
|
17
|
+
# the framework and any gems in your application.
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
|
15
|
+
# Enable/disable caching. By default caching is disabled.
|
16
|
+
# Run rails dev:cache to toggle caching.
|
17
|
+
if Rails.root.join('tmp', 'caching-dev.txt').exist?
|
18
|
+
config.action_controller.perform_caching = true
|
19
|
+
|
20
|
+
config.cache_store = :memory_store
|
21
|
+
config.public_file_server.headers = {
|
22
|
+
'Cache-Control' => "public, max-age=#{2.days.to_i}"
|
23
|
+
}
|
24
|
+
else
|
25
|
+
config.action_controller.perform_caching = false
|
26
|
+
|
27
|
+
config.cache_store = :null_store
|
28
|
+
end
|
29
|
+
|
30
|
+
# Don't care if the mailer can't send.
|
31
|
+
config.action_mailer.raise_delivery_errors = false
|
32
|
+
|
33
|
+
config.action_mailer.perform_caching = false
|
34
|
+
|
35
|
+
# Print deprecation notices to the Rails logger.
|
36
|
+
config.active_support.deprecation = :log
|
37
|
+
|
38
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
39
|
+
# This option may cause significant delays in view rendering with a large
|
40
|
+
# number of complex assets.
|
41
|
+
config.assets.debug = true
|
42
|
+
|
43
|
+
# Suppress logger output for asset requests.
|
44
|
+
config.assets.quiet = true
|
45
|
+
|
46
|
+
# Raises error for missing translations
|
47
|
+
# config.action_view.raise_on_missing_translations = true
|
48
|
+
|
49
|
+
# Use an evented file watcher to asynchronously detect changes in source code,
|
50
|
+
# routes, locales, etc. This feature depends on the listen gem.
|
51
|
+
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
52
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# Code is not reloaded between requests.
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both threaded web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
14
|
+
config.consider_all_requests_local = false
|
15
|
+
config.action_controller.perform_caching = true
|
16
|
+
|
17
|
+
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
18
|
+
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
19
|
+
# config.require_master_key = true
|
20
|
+
|
21
|
+
# Disable serving static files from the `/public` folder by default since
|
22
|
+
# Apache or NGINX already handles this.
|
23
|
+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
24
|
+
|
25
|
+
# Compress JavaScripts and CSS.
|
26
|
+
config.assets.js_compressor = :uglifier
|
27
|
+
# config.assets.css_compressor = :sass
|
28
|
+
|
29
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
30
|
+
config.assets.compile = false
|
31
|
+
|
32
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
35
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
36
|
+
|
37
|
+
# Specifies the header that your server uses for sending files.
|
38
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
39
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
40
|
+
|
41
|
+
# Mount Action Cable outside main process or domain
|
42
|
+
# config.action_cable.mount_path = nil
|
43
|
+
# config.action_cable.url = 'wss://example.com/cable'
|
44
|
+
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
45
|
+
|
46
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
47
|
+
# config.force_ssl = true
|
48
|
+
|
49
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
50
|
+
# when problems arise.
|
51
|
+
config.log_level = :debug
|
52
|
+
|
53
|
+
# Prepend all log lines with the following tags.
|
54
|
+
config.log_tags = [ :request_id ]
|
55
|
+
|
56
|
+
# Use a different cache store in production.
|
57
|
+
# config.cache_store = :mem_cache_store
|
58
|
+
|
59
|
+
# Use a real queuing backend for Active Job (and separate queues per environment)
|
60
|
+
# config.active_job.queue_adapter = :resque
|
61
|
+
# config.active_job.queue_name_prefix = "dummy_rails_#{Rails.env}"
|
62
|
+
|
63
|
+
config.action_mailer.perform_caching = false
|
64
|
+
|
65
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
66
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
67
|
+
# config.action_mailer.raise_delivery_errors = false
|
68
|
+
|
69
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
70
|
+
# the I18n.default_locale when a translation cannot be found).
|
71
|
+
config.i18n.fallbacks = true
|
72
|
+
|
73
|
+
# Send deprecation notices to registered listeners.
|
74
|
+
config.active_support.deprecation = :notify
|
75
|
+
|
76
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
77
|
+
config.log_formatter = ::Logger::Formatter.new
|
78
|
+
|
79
|
+
# Use a different logger for distributed setups.
|
80
|
+
# require 'syslog/logger'
|
81
|
+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
82
|
+
|
83
|
+
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
84
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
85
|
+
logger.formatter = config.log_formatter
|
86
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
87
|
+
end
|
88
|
+
end
|