resque_stuck_queue 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- data.tar.gz: 4afb591b2c6fd8c3fc37a27dd92d54af07de3e2e
4
- metadata.gz: 19702480a46ba718628bcb98c6f0eab1fa0c2261
3
+ metadata.gz: 4e70424faa8ec9ad5fe004e176521d4563b6b585
4
+ data.tar.gz: 11fb88f2d886993e99fbdd65ec2ec0f4a1b62d1a
5
5
  SHA512:
6
- data.tar.gz: b05278c44a84b631e5e43a1e1ba84f3d29971e075526cf16d926ed8dbb921b8399f3da4aa4a309b4f50e90c6722a5b8dbfdf1b0219c22153cc7e558e02377b6b
7
- metadata.gz: 727b6ec883cf0fdec4a23a4235675309c7ea321704e204991eddfc311432e846392432799837a153d55429b8518ddd39936caca101d8541760bf80f8c7aa1d80
6
+ metadata.gz: 9c4b847e85b9b3741690a131a883d77cb7906099a1f8fada7b5139505e7a69f2a5c66a49c4ca3a35e0eab921d5c68fe0d43567291774d811ec69cc6256f510e7
7
+ data.tar.gz: 62750b5b3736c284c9f10f58b37344e4750e4e0454d68a2016636d73854186b2eed89eef9eb7456866927103003c8803112aae48582a6e5050fd68f5241c4eea
data/README.md CHANGED
@@ -35,34 +35,36 @@ require 'resque_stuck_queue' # or require 'resque/stuck_queue'
35
35
  require 'logger'
36
36
 
37
37
  # change to decent values that make sense for you
38
- Resque::StuckQueue.config[:heartbeat_interval] = 10.seconds
39
- Resque::StuckQueue.config[:trigger_timeout] = 30.seconds
40
-
41
- # create a sync/unbuffered log
42
- logpath = Rails.root.join('log', 'resque_stuck_queue.log')
43
- logfile = File.open(logpath, "a")
44
- logfile.sync = true
45
- logger = Logger.new(logfile)
46
- logger.formatter = Logger::Formatter.new
47
- Resque::StuckQueue.config[:logger] = logger
48
-
49
- Resque::StuckQueue.config[:redis] = YOUR_REDIS
38
+ Resque::StuckQueue.config[:heartbeat_interval] = 10.seconds
39
+ Resque::StuckQueue.config[:watcher_interval] = 1.seconds
40
+ Resque::StuckQueue.config[:trigger_timeout] = 30.seconds
50
41
 
51
42
  # which queues to monitor
52
- Resque::StuckQueue.config[:queues] = [:app, :custom_queue]
43
+ Resque::StuckQueue.config[:queues] = [:app, :custom_queue]
53
44
 
54
45
  # handler for when a resque queue is being problematic
55
- Resque::StuckQueue.config[:triggered_handler] = proc { |bad_queue, lagtime|
46
+ Resque::StuckQueue.config[:triggered_handler] = proc { |bad_queue, lagtime|
56
47
  msg = "[BAD] AWSM #{Rails.env}'s Resque #{bad_queue} queue lagging job execution by #{lagtime} seconds."
57
48
  send_email(msg)
58
49
  }
59
50
 
60
51
  # handler for when a resque queue recovers
61
- Resque::StuckQueue.config[:recovered_handler] = proc { |good_queue, lagtime|
52
+ Resque::StuckQueue.config[:recovered_handler] = proc { |good_queue, lagtime|
62
53
  msg = "[GOOD] AWSM #{Rails.env}'s Resque #{good_queue} queue lagging job execution by #{lagtime} seconds."
63
54
  send_email(msg)
64
55
  }
65
56
 
57
+ # create a sync/unbuffered log
58
+ logpath = Rails.root.join('log', 'resque_stuck_queue.log')
59
+ logfile = File.open(logpath, "a")
60
+ logfile.sync = true
61
+ logger = Logger.new(logfile)
62
+ logger.formatter = Logger::Formatter.new
63
+ Resque::StuckQueue.config[:logger] = logger
64
+
65
+ # your own redis
66
+ Resque::StuckQueue.config[:redis] = YOUR_REDIS
67
+
66
68
  </pre>
67
69
 
68
70
  Then create a task to run it as a daemon (similar to how the resque rake job is implemented):
data/THOUGHTS CHANGED
@@ -1,20 +1,4 @@
1
- other resources:
2
-
3
- http://vitobotta.com/resque-automatically-kill-stuck-workers-retry-failed-jobs/#sthash.oQsaNeb5.dpbs
4
- http://stackoverflow.com/questions/10757758/find-out-if-a-resque-job-is-still-running-and-kill-it-if-its-stuck
5
-
6
1
  ## TODOS
7
2
 
8
- add a 'resque_stuck_queue/tasks' bit? See tres eg
9
- add a trap{} to force_stop. ok for overwriting process's trap handlers? use config for that?
10
-
11
- fix skeleton recipe https://github.com/shaiguitar/resque_stuck_queue/blame/master/README.md#L103
12
- raise appname, => :environment, log path
13
-
14
- investigate: why is temple getting triggered? how often? is the enqueing/checking taking too much time?
15
- also, if one queue is bad, does it trigger other queue's handlers? write some tests, asshole.
16
- woes of redis namespace, in regards to Awsm.redis != Resque.redis etc. (which is important for setting the key through @redis)
17
-
18
- with lag time, it will continue to trigger, for every heartbeat time it's supposed to tick, find some way to do that, and then maybe add some resolved handler/proc?
19
-
20
3
  rm redis locking (since it works by keys now, no need for it, recover/trigger ping pong).
4
+ rm require resque?
@@ -54,9 +54,17 @@ module Resque
54
54
  @queues ||= (config[:queues] || [:app])
55
55
  end
56
56
 
57
+ def abort_on_exception
58
+ if !config[:abort_on_exception].nil?
59
+ config[:abort_on_exception] # allow overriding w false
60
+ else
61
+ true # default
62
+ end
63
+ end
64
+
57
65
  def start_in_background
58
66
  Thread.new do
59
- Thread.current.abort_on_exception = config[:abort_on_exception]
67
+ Thread.current.abort_on_exception = abort_on_exception
60
68
  self.start
61
69
  end
62
70
  end
@@ -127,7 +135,7 @@ module Resque
127
135
 
128
136
  def setup_heartbeat_thread
129
137
  @threads << Thread.new do
130
- Thread.current.abort_on_exception = config[:abort_on_exception]
138
+ Thread.current.abort_on_exception = abort_on_exception
131
139
  logger.info("Starting heartbeat thread")
132
140
  while @running
133
141
  # we want to go through resque jobs, because that's what we're trying to test here:
@@ -154,7 +162,7 @@ module Resque
154
162
 
155
163
  def setup_watcher_thread
156
164
  @threads << Thread.new do
157
- Thread.current.abort_on_exception = config[:abort_on_exception]
165
+ Thread.current.abort_on_exception = abort_on_exception
158
166
  logger.info("Starting watcher thread")
159
167
  while @running
160
168
  mutex = Redis::Mutex.new('resque_stuck_queue_lock', block: 0)
@@ -29,7 +29,7 @@ module Resque
29
29
  :triggered_key => "optional, name of keys to keep track of the last trigger time",
30
30
  :logger => "optional, pass a Logger. Default a ruby logger will be instantiated. Needs to respond to that interface.",
31
31
  :queues => "optional, monitor specific queues you want to send a heartbeat/monitor to. default is [:app]",
32
- :abort_on_exception => "optional, if you want the resque-stuck-queue threads to explicitly raise, default is false",
32
+ :abort_on_exception => "optional, if you want the resque-stuck-queue threads to explicitly raise, default is true",
33
33
  :heartbeat_job => "optional, your own custom refreshing job. if you are using something other than resque",
34
34
  :enable_signals => "optional, allow resque::stuck's signal_handlers which do mostly nothing at this point.",
35
35
  }
@@ -1,5 +1,5 @@
1
1
  module Resque
2
2
  module StuckQueue
3
- VERSION = "0.4.2"
3
+ VERSION = "0.4.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_stuck_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shai Rosenfeld
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-02-02 00:00:00 Z
12
+ date: 2014-02-04 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis-mutex