sidekiq-heartbeat_monitor 1.0.0.2 → 1.0.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f506a3446df89fe6dbb973020355ecd670b04532
|
4
|
+
data.tar.gz: 9efa759217ce9ccaf1a56b97110f8508542c4645
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5eb0f1443d34e99930f328cb004a9f1165bf18af47e6df24ba3a3d1752871ad34d0826f9f88f362d138f2d1a230c965312a8a42a0e93b267ca3e2f414f4cc060
|
7
|
+
data.tar.gz: b0858151518b1095a8a3484adebf867cb5876008ea3e286417b1ab344d7dd562724b7f8dd353722861c2338cff6af2bfc3195a205d29852796ee40a81fbc0bb5
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Sidekiq
|
1
|
+
# Sidekiq Montior Gem
|
2
2
|
|
3
3
|
This gem adds 2 things:
|
4
4
|
1. A lightweight heartbeat task that runs every few minutes and alerts if it takes longer than a few seconds to start.
|
@@ -61,15 +61,6 @@ Sidekiq::HeartbeatMonitor.configure(
|
|
61
61
|
|
62
62
|
**Note:** `on_backed_up` and `on_slowed_down` accept an array and will always add to existing callbacks (you can combine `slack_notiifer_url` with them)
|
63
63
|
|
64
|
-
### STEP 3. Schedule recurring task
|
65
|
-
If you're using sidekiq-cron, add this to your `config/scheduler.yml` file:
|
66
|
-
```yml
|
67
|
-
sidekiq_heartbeat_monitor:
|
68
|
-
cron: "*/15 * * * * *" # Heart beat runs every 15 seconds in this case
|
69
|
-
class: "Sidekiq::HeartbeatMonitor::Scheduler"
|
70
|
-
queue: scheduler
|
71
|
-
```
|
72
|
-
|
73
64
|
## Testing Your Config
|
74
65
|
To test your config:
|
75
66
|
1. Open your rails console.
|
@@ -18,6 +18,10 @@ module Sidekiq
|
|
18
18
|
@on_backed_up = @on_backed_up.to_a + slack_notifier_callback
|
19
19
|
@on_slowed_down = @on_slowed_down.to_a + slack_notifier_callback
|
20
20
|
end
|
21
|
+
|
22
|
+
unless Sidekiq::Cron::Job.find("sidekiq_monitor").present?
|
23
|
+
Sidekiq::Cron::Job.create(name: 'sidekiq_monitor', cron: '*/15 * * * * *', class: 'Sidekiq::HeartbeatMonitor::Scheduler')
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
def send_test!
|
@@ -10,7 +10,7 @@ module Sidekiq
|
|
10
10
|
Sidekiq::Queue.all.each do |q|
|
11
11
|
check_queue_size(q, Sidekiq::HeartbeatMonitor::Config.max_queue_size)
|
12
12
|
|
13
|
-
Sidekiq::HeartbeatMonitor::Worker.
|
13
|
+
Sidekiq::HeartbeatMonitor::Worker.client_push('class' => self, 'args' => [q.name, 15], 'queue' => q.name)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -10,7 +10,7 @@ module Sidekiq
|
|
10
10
|
# @param queue_name [String] Name of the queue that this heartbeat is running on.
|
11
11
|
def perform(queue_name, secs_between_beats = 15)
|
12
12
|
current_run_at = Time.now.utc.to_i
|
13
|
-
last_run_at =
|
13
|
+
last_run_at = redis.get("Sidekiq/HeartbeatMonitor/Worker/#{queue_name}.last_run_at").to_i
|
14
14
|
|
15
15
|
if last_run_at > 0
|
16
16
|
time_since_last_run = current_run_at - last_run_at
|
@@ -21,7 +21,7 @@ module Sidekiq
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
redis.set("Sidekiq/HeartbeatMonitor/Worker/#{queue_name}.last_run_at", current_run_at, ex: 1.hour)
|
25
25
|
end
|
26
26
|
|
27
27
|
##
|
@@ -35,6 +35,11 @@ module Sidekiq
|
|
35
35
|
true
|
36
36
|
end
|
37
37
|
|
38
|
+
private
|
39
|
+
|
40
|
+
def redis
|
41
|
+
@@redis = defined?($redis) ? $redis : Redis.new
|
42
|
+
end
|
38
43
|
|
39
44
|
end
|
40
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-heartbeat_monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay El-Kaake
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dont_repeat_for
|