mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Refactor #4502 a bit
This commit is contained in:
parent
2504d0b7ac
commit
0b44ca19b5
2 changed files with 10 additions and 4 deletions
|
@ -5,8 +5,8 @@
|
|||
HEAD
|
||||
---------
|
||||
|
||||
- Fix: Do not connect to redis at ruby vm exit when not needed. [#4502]
|
||||
- Refactor systemd integration to work better with custom binaries [#4511]
|
||||
- Don't connect to Redis at process exit if not needed [#4502]
|
||||
- Remove Redis connection naming [#4479]
|
||||
|
||||
6.0.6
|
||||
|
|
|
@ -97,10 +97,12 @@ module Sidekiq
|
|||
end
|
||||
|
||||
def self.flush_stats
|
||||
nowdate = Time.now.utc.strftime("%Y-%m-%d")
|
||||
fails = Processor::FAILURE.reset
|
||||
procd = Processor::PROCESSED.reset
|
||||
if fails + procd > 0
|
||||
return if fails + procd == 0
|
||||
|
||||
nowdate = Time.now.utc.strftime("%Y-%m-%d")
|
||||
begin
|
||||
Sidekiq.redis do |conn|
|
||||
conn.pipelined do
|
||||
conn.incrby("stat:processed", procd)
|
||||
|
@ -112,6 +114,10 @@ module Sidekiq
|
|||
conn.expire("stat:failed:#{nowdate}", STATS_TTL)
|
||||
end
|
||||
end
|
||||
rescue => ex
|
||||
# we're exiting the process, things might be shut down so don't
|
||||
# try to handle the exception
|
||||
Sidekiq.logger.warn("Unable to flush stats: #{ex}")
|
||||
end
|
||||
end
|
||||
at_exit(&method(:flush_stats))
|
||||
|
@ -166,7 +172,7 @@ module Sidekiq
|
|||
::Process.kill(msg, ::Process.pid)
|
||||
rescue => e
|
||||
# ignore all redis/network issues
|
||||
logger.error("heartbeat: #{e.message}")
|
||||
logger.error("heartbeat: #{e}")
|
||||
# don't lose the counts if there was a network issue
|
||||
Processor::PROCESSED.incr(procd)
|
||||
Processor::FAILURE.incr(fails)
|
||||
|
|
Loading…
Add table
Reference in a new issue