resque-mongo 1.8.1 → 1.9.8.1
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.
- data/HISTORY.md +70 -0
- data/README.markdown +7 -2
- data/Rakefile +25 -30
- data/lib/resque.rb +9 -10
- data/lib/resque/failure/hoptoad.rb +2 -2
- data/lib/resque/failure/mongo.rb +3 -3
- data/lib/resque/failure/multiple.rb +11 -5
- data/lib/resque/job.rb +2 -1
- data/lib/resque/server.rb +2 -2
- data/lib/resque/server/test_helper.rb +1 -1
- data/lib/resque/server/views/failed.erb +8 -4
- data/lib/resque/server/views/layout.erb +1 -1
- data/lib/resque/server/views/stats.erb +2 -2
- data/lib/resque/tasks.rb +1 -1
- data/lib/resque/version.rb +1 -1
- data/lib/resque/worker.rb +1 -1
- data/tasks/redis.rake +3 -3
- data/test/job_hooks_test.rb +14 -14
- data/test/job_plugins_test.rb +29 -8
- data/test/plugin_test.rb +8 -8
- data/test/redis-test.conf +0 -17
- data/test/resque-web_test.rb +0 -20
- metadata +47 -73
- data/.gitignore +0 -3
- data/.kick +0 -26
- data/CONTRIBUTORS +0 -32
- data/config.ru +0 -14
- data/deps.rip +0 -8
- data/docs/HOOKS.md +0 -121
- data/docs/PLUGINS.md +0 -93
- data/examples/async_helper.rb +0 -31
- data/examples/demo/README.markdown +0 -71
- data/examples/demo/Rakefile +0 -8
- data/examples/demo/app.rb +0 -38
- data/examples/demo/config.ru +0 -19
- data/examples/demo/job.rb +0 -22
- data/examples/god/resque.god +0 -53
- data/examples/god/stale.god +0 -26
- data/examples/instance.rb +0 -11
- data/examples/monit/resque.monit +0 -6
- data/examples/simple.rb +0 -30
- data/init.rb +0 -1
data/examples/demo/config.ru
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'logger'
|
3
|
-
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
|
4
|
-
require 'app'
|
5
|
-
require 'resque/server'
|
6
|
-
|
7
|
-
use Rack::ShowExceptions
|
8
|
-
|
9
|
-
# Set the AUTH env variable to your basic auth password to protect Resque.
|
10
|
-
AUTH_PASSWORD = ENV['AUTH']
|
11
|
-
if AUTH_PASSWORD
|
12
|
-
Resque::Server.use Rack::Auth::Basic do |username, password|
|
13
|
-
password == AUTH_PASSWORD
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
run Rack::URLMap.new \
|
18
|
-
"/" => Demo::App.new,
|
19
|
-
"/resque" => Resque::Server.new
|
data/examples/demo/job.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'resque'
|
2
|
-
|
3
|
-
module Demo
|
4
|
-
module Job
|
5
|
-
@queue = :default
|
6
|
-
|
7
|
-
def self.perform(params)
|
8
|
-
sleep 1
|
9
|
-
puts "Processed a job!"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module FailingJob
|
14
|
-
@queue = :failing
|
15
|
-
|
16
|
-
def self.perform(params)
|
17
|
-
sleep 1
|
18
|
-
raise 'not processable!'
|
19
|
-
puts "Processed a job!"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/examples/god/resque.god
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
rails_env = ENV['RAILS_ENV'] || "production"
|
2
|
-
rails_root = ENV['RAILS_ROOT'] || "/data/github/current"
|
3
|
-
num_workers = rails_env == 'production' ? 5 : 2
|
4
|
-
|
5
|
-
num_workers.times do |num|
|
6
|
-
God.watch do |w|
|
7
|
-
w.name = "resque-#{num}"
|
8
|
-
w.group = 'resque'
|
9
|
-
w.interval = 30.seconds
|
10
|
-
w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env}
|
11
|
-
w.start = "/usr/bin/rake -f #{rails_root}/Rakefile environment resque:work"
|
12
|
-
|
13
|
-
w.uid = 'git'
|
14
|
-
w.gid = 'git'
|
15
|
-
|
16
|
-
# retart if memory gets too high
|
17
|
-
w.transition(:up, :restart) do |on|
|
18
|
-
on.condition(:memory_usage) do |c|
|
19
|
-
c.above = 350.megabytes
|
20
|
-
c.times = 2
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# determine the state on startup
|
25
|
-
w.transition(:init, { true => :up, false => :start }) do |on|
|
26
|
-
on.condition(:process_running) do |c|
|
27
|
-
c.running = true
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# determine when process has finished starting
|
32
|
-
w.transition([:start, :restart], :up) do |on|
|
33
|
-
on.condition(:process_running) do |c|
|
34
|
-
c.running = true
|
35
|
-
c.interval = 5.seconds
|
36
|
-
end
|
37
|
-
|
38
|
-
# failsafe
|
39
|
-
on.condition(:tries) do |c|
|
40
|
-
c.times = 5
|
41
|
-
c.transition = :start
|
42
|
-
c.interval = 5.seconds
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# start if process is not running
|
47
|
-
w.transition(:up, :start) do |on|
|
48
|
-
on.condition(:process_running) do |c|
|
49
|
-
c.running = false
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/examples/god/stale.god
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# This will ride alongside god and kill any rogue stale worker
|
2
|
-
# processes. Their sacrifice is for the greater good.
|
3
|
-
|
4
|
-
WORKER_TIMEOUT = 60 * 10 # 10 minutes
|
5
|
-
|
6
|
-
Thread.new do
|
7
|
-
loop do
|
8
|
-
begin
|
9
|
-
`ps -e -o pid,command | grep [r]esque`.split("\n").each do |line|
|
10
|
-
parts = line.split(' ')
|
11
|
-
next if parts[-2] != "at"
|
12
|
-
started = parts[-1].to_i
|
13
|
-
elapsed = Time.now - Time.at(started)
|
14
|
-
|
15
|
-
if elapsed >= WORKER_TIMEOUT
|
16
|
-
::Process.kill('USR1', parts[0].to_i)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
rescue
|
20
|
-
# don't die because of stupid exceptions
|
21
|
-
nil
|
22
|
-
end
|
23
|
-
|
24
|
-
sleep 30
|
25
|
-
end
|
26
|
-
end
|
data/examples/instance.rb
DELETED
data/examples/monit/resque.monit
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
check process resque_worker_QUEUE
|
2
|
-
with pidfile /data/APP_NAME/current/tmp/pids/resque_worker_QUEUE.pid
|
3
|
-
start program = "/bin/sh -c 'cd /data/APP_NAME/current; RAILS_ENV=production QUEUE=queue_name VERBOSE=1 nohup rake resque:work& &> log/resque_worker_QUEUE.log && echo $! > tmp/pids/resque_worker_QUEUE.pid'" as uid deploy and gid deploy
|
4
|
-
stop program = "/bin/sh -c 'cd /data/APP_NAME/current && kill -s QUIT `cat tmp/pids/resque_worker_QUEUE.pid` && rm -f tmp/pids/resque_worker_QUEUE.pid; exit 0;'"
|
5
|
-
if totalmem is greater than 300 MB for 10 cycles then restart # eating up memory?
|
6
|
-
group resque_workers
|
data/examples/simple.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# This is a simple Resque job.
|
2
|
-
class Archive
|
3
|
-
@queue = :file_serve
|
4
|
-
|
5
|
-
def self.perform(repo_id, branch = 'master')
|
6
|
-
repo = Repository.find(repo_id)
|
7
|
-
repo.create_archive(branch)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
# This is in our app code
|
12
|
-
class Repository < Model
|
13
|
-
# ... stuff ...
|
14
|
-
|
15
|
-
def async_create_archive(branch)
|
16
|
-
Resque.enqueue(Archive, self.id, branch)
|
17
|
-
end
|
18
|
-
|
19
|
-
# ... more stuff ...
|
20
|
-
end
|
21
|
-
|
22
|
-
# Calling this code:
|
23
|
-
repo = Repository.find(22)
|
24
|
-
repo.async_create_archive('homebrew')
|
25
|
-
|
26
|
-
# Will return immediately and create a Resque job which is later
|
27
|
-
# processed.
|
28
|
-
|
29
|
-
# Essentially, this code is run by the worker when processing:
|
30
|
-
Archive.perform(22, 'homebrew')
|
data/init.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'resque'
|