sidekiq 5.2.10 → 6.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sidekiq might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.standard.yml +20 -0
- data/.travis.yml +5 -2
- data/6.0-Upgrade.md +58 -0
- data/Changes.md +21 -16
- data/Gemfile +15 -10
- data/Rakefile +5 -4
- data/bin/sidekiqctl +1 -10
- data/lib/generators/sidekiq/worker_generator.rb +12 -14
- data/lib/sidekiq/api.rb +133 -148
- data/lib/sidekiq/cli.rb +95 -147
- data/lib/sidekiq/client.rb +44 -45
- data/lib/sidekiq/ctl.rb +35 -109
- data/lib/sidekiq/delay.rb +5 -6
- data/lib/sidekiq/exception_handler.rb +10 -12
- data/lib/sidekiq/extensions/action_mailer.rb +10 -20
- data/lib/sidekiq/extensions/active_record.rb +9 -7
- data/lib/sidekiq/extensions/class_methods.rb +9 -7
- data/lib/sidekiq/extensions/generic_proxy.rb +4 -4
- data/lib/sidekiq/fetch.rb +5 -6
- data/lib/sidekiq/job_logger.rb +37 -7
- data/lib/sidekiq/job_retry.rb +45 -58
- data/lib/sidekiq/launcher.rb +59 -48
- data/lib/sidekiq/logger.rb +69 -0
- data/lib/sidekiq/manager.rb +6 -8
- data/lib/sidekiq/middleware/chain.rb +2 -1
- data/lib/sidekiq/middleware/i18n.rb +5 -7
- data/lib/sidekiq/paginator.rb +11 -12
- data/lib/sidekiq/processor.rb +42 -45
- data/lib/sidekiq/rails.rb +2 -26
- data/lib/sidekiq/redis_connection.rb +31 -37
- data/lib/sidekiq/scheduled.rb +17 -19
- data/lib/sidekiq/testing/inline.rb +2 -1
- data/lib/sidekiq/testing.rb +22 -23
- data/lib/sidekiq/util.rb +18 -15
- data/lib/sidekiq/version.rb +2 -1
- data/lib/sidekiq/web/action.rb +15 -11
- data/lib/sidekiq/web/application.rb +59 -59
- data/lib/sidekiq/web/helpers.rb +66 -67
- data/lib/sidekiq/web/router.rb +17 -14
- data/lib/sidekiq/web.rb +36 -44
- data/lib/sidekiq/worker.rb +12 -13
- data/lib/sidekiq.rb +53 -42
- data/sidekiq.gemspec +7 -7
- metadata +20 -32
- data/lib/sidekiq/core_ext.rb +0 -1
- data/lib/sidekiq/logging.rb +0 -122
- data/lib/sidekiq/middleware/server/active_record.rb +0 -23
data/lib/sidekiq/logging.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'time'
|
3
|
-
require 'logger'
|
4
|
-
require 'fcntl'
|
5
|
-
|
6
|
-
module Sidekiq
|
7
|
-
module Logging
|
8
|
-
|
9
|
-
class Pretty < Logger::Formatter
|
10
|
-
SPACE = " "
|
11
|
-
|
12
|
-
# Provide a call() method that returns the formatted message.
|
13
|
-
def call(severity, time, program_name, message)
|
14
|
-
"#{time.utc.iso8601(3)} #{::Process.pid} TID-#{Sidekiq::Logging.tid}#{context} #{severity}: #{message}\n"
|
15
|
-
end
|
16
|
-
|
17
|
-
def context
|
18
|
-
c = Thread.current[:sidekiq_context]
|
19
|
-
" #{c.join(SPACE)}" if c && c.any?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class WithoutTimestamp < Pretty
|
24
|
-
def call(severity, time, program_name, message)
|
25
|
-
"#{::Process.pid} TID-#{Sidekiq::Logging.tid}#{context} #{severity}: #{message}\n"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.tid
|
30
|
-
Thread.current['sidekiq_tid'] ||= (Thread.current.object_id ^ ::Process.pid).to_s(36)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.job_hash_context(job_hash)
|
34
|
-
# If we're using a wrapper class, like ActiveJob, use the "wrapped"
|
35
|
-
# attribute to expose the underlying thing.
|
36
|
-
klass = job_hash['wrapped'] || job_hash["class"]
|
37
|
-
bid = job_hash['bid']
|
38
|
-
"#{klass} JID-#{job_hash['jid']}#{" BID-#{bid}" if bid}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.with_job_hash_context(job_hash, &block)
|
42
|
-
with_context(job_hash_context(job_hash), &block)
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.with_context(msg)
|
46
|
-
Thread.current[:sidekiq_context] ||= []
|
47
|
-
Thread.current[:sidekiq_context] << msg
|
48
|
-
yield
|
49
|
-
ensure
|
50
|
-
Thread.current[:sidekiq_context].pop
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.initialize_logger(log_target = STDOUT)
|
54
|
-
oldlogger = defined?(@logger) ? @logger : nil
|
55
|
-
@logger = Logger.new(log_target)
|
56
|
-
@logger.level = Logger::INFO
|
57
|
-
@logger.formatter = ENV['DYNO'] ? WithoutTimestamp.new : Pretty.new
|
58
|
-
oldlogger.close if oldlogger && !$TESTING # don't want to close testing's STDOUT logging
|
59
|
-
@logger
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.logger
|
63
|
-
defined?(@logger) ? @logger : initialize_logger
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.logger=(log)
|
67
|
-
@logger = (log ? log : Logger.new(File::NULL))
|
68
|
-
end
|
69
|
-
|
70
|
-
# This reopens ALL logfiles in the process that have been rotated
|
71
|
-
# using logrotate(8) (without copytruncate) or similar tools.
|
72
|
-
# A +File+ object is considered for reopening if it is:
|
73
|
-
# 1) opened with the O_APPEND and O_WRONLY flags
|
74
|
-
# 2) the current open file handle does not match its original open path
|
75
|
-
# 3) unbuffered (as far as userspace buffering goes, not O_SYNC)
|
76
|
-
# Returns the number of files reopened
|
77
|
-
def self.reopen_logs
|
78
|
-
to_reopen = []
|
79
|
-
append_flags = File::WRONLY | File::APPEND
|
80
|
-
|
81
|
-
ObjectSpace.each_object(File) do |fp|
|
82
|
-
begin
|
83
|
-
if !fp.closed? && fp.stat.file? && fp.sync && (fp.fcntl(Fcntl::F_GETFL) & append_flags) == append_flags
|
84
|
-
to_reopen << fp
|
85
|
-
end
|
86
|
-
rescue IOError, Errno::EBADF
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
nr = 0
|
91
|
-
to_reopen.each do |fp|
|
92
|
-
orig_st = begin
|
93
|
-
fp.stat
|
94
|
-
rescue IOError, Errno::EBADF
|
95
|
-
next
|
96
|
-
end
|
97
|
-
|
98
|
-
begin
|
99
|
-
b = File.stat(fp.path)
|
100
|
-
next if orig_st.ino == b.ino && orig_st.dev == b.dev
|
101
|
-
rescue Errno::ENOENT
|
102
|
-
end
|
103
|
-
|
104
|
-
begin
|
105
|
-
File.open(fp.path, 'a') { |tmpfp| fp.reopen(tmpfp) }
|
106
|
-
fp.sync = true
|
107
|
-
nr += 1
|
108
|
-
rescue IOError, Errno::EBADF
|
109
|
-
# not much we can do...
|
110
|
-
end
|
111
|
-
end
|
112
|
-
nr
|
113
|
-
rescue RuntimeError => ex
|
114
|
-
# RuntimeError: ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable
|
115
|
-
puts "Unable to reopen logs: #{ex.message}"
|
116
|
-
end
|
117
|
-
|
118
|
-
def logger
|
119
|
-
Sidekiq::Logging.logger
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Sidekiq
|
3
|
-
module Middleware
|
4
|
-
module Server
|
5
|
-
class ActiveRecord
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
# With Rails 5+ we must use the Reloader **always**.
|
9
|
-
# The reloader handles code loading and db connection management.
|
10
|
-
if defined?(::Rails) && defined?(::Rails::VERSION) && ::Rails::VERSION::MAJOR >= 5
|
11
|
-
raise ArgumentError, "Rails 5 no longer needs or uses the ActiveRecord middleware."
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(*args)
|
16
|
-
yield
|
17
|
-
ensure
|
18
|
-
::ActiveRecord::Base.clear_active_connections!
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|