resque 1.8.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of resque might be problematic. Click here for more details.
- data/Rakefile +11 -45
- data/lib/resque.rb +3 -2
- data/lib/resque/failure/multiple.rb +9 -5
- data/lib/resque/server/views/failed.erb +6 -2
- data/lib/resque/version.rb +1 -1
- metadata +49 -73
- data/.gitignore +0 -3
- data/.kick +0 -26
- data/CONTRIBUTORS +0 -32
- data/HISTORY.md +0 -132
- data/config.ru +0 -14
- data/deps.rip +0 -7
- 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/tasks/redis.rake +0 -159
- data/tasks/resque.rake +0 -2
data/Rakefile
CHANGED
@@ -42,47 +42,12 @@ end
|
|
42
42
|
|
43
43
|
task :install => [ 'redis:install', 'dtach:install' ]
|
44
44
|
|
45
|
-
desc "Build a gem"
|
46
|
-
task :gem => [ :test, :gemspec, :build ]
|
47
|
-
|
48
45
|
begin
|
49
|
-
require '
|
50
|
-
|
51
|
-
|
52
|
-
Jeweler::Tasks.new do |gemspec|
|
53
|
-
gemspec.name = "resque"
|
54
|
-
gemspec.summary = "Resque is a Redis-backed queueing system."
|
55
|
-
gemspec.email = "chris@ozmm.org"
|
56
|
-
gemspec.homepage = "http://github.com/defunkt/resque"
|
57
|
-
gemspec.authors = ["Chris Wanstrath"]
|
58
|
-
gemspec.version = Resque::Version
|
59
|
-
|
60
|
-
gemspec.add_dependency "redis"
|
61
|
-
gemspec.add_dependency "redis-namespace"
|
62
|
-
gemspec.add_dependency "vegas", ">=0.1.2"
|
63
|
-
gemspec.add_dependency "sinatra", ">=0.9.2"
|
64
|
-
gemspec.add_development_dependency "jeweler"
|
65
|
-
|
66
|
-
gemspec.description = <<description
|
67
|
-
Resque is a Redis-backed Ruby library for creating background jobs,
|
68
|
-
placing those jobs on multiple queues, and processing them later.
|
69
|
-
|
70
|
-
Background jobs can be any Ruby class or module that responds to
|
71
|
-
perform. Your existing classes can easily be converted to background
|
72
|
-
jobs or you can create new classes specifically to do work. Or, you
|
73
|
-
can do both.
|
74
|
-
|
75
|
-
Resque is heavily inspired by DelayedJob (which rocks) and is
|
76
|
-
comprised of three parts:
|
77
|
-
|
78
|
-
* A Ruby library for creating, querying, and processing jobs
|
79
|
-
* A Rake task for starting a worker which processes jobs
|
80
|
-
* A Sinatra app for monitoring queues, jobs, and workers.
|
81
|
-
description
|
82
|
-
end
|
46
|
+
require 'mg'
|
47
|
+
MG.new("resque.gemspec")
|
83
48
|
rescue LoadError
|
84
|
-
|
85
|
-
|
49
|
+
warn "mg not available."
|
50
|
+
warn "Install it with: gem i mg"
|
86
51
|
end
|
87
52
|
|
88
53
|
|
@@ -102,11 +67,12 @@ end
|
|
102
67
|
#
|
103
68
|
|
104
69
|
desc "Push a new version to Gemcutter"
|
105
|
-
task :publish =>
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
70
|
+
task :publish => "gem:publish" do
|
71
|
+
require 'resque/version'
|
72
|
+
|
73
|
+
sh "git tag v#{Resque::Version}"
|
74
|
+
sh "git push origin v#{Resque::Version}"
|
75
|
+
sh "git push origin master"
|
76
|
+
sh "git clean -fd"
|
111
77
|
exec "rake pages"
|
112
78
|
end
|
data/lib/resque.rb
CHANGED
@@ -26,7 +26,8 @@ module Resque
|
|
26
26
|
# Accepts:
|
27
27
|
# 1. A 'hostname:port' string
|
28
28
|
# 2. A 'hostname:port:db' string (to select the Redis db)
|
29
|
-
# 3. An instance of `Redis`, `Redis::Client`,
|
29
|
+
# 3. An instance of `Redis`, `Redis::Client`, `Redis::DistRedis`,
|
30
|
+
# or `Redis::Namespace`.
|
30
31
|
def redis=(server)
|
31
32
|
case server
|
32
33
|
when String
|
@@ -34,7 +35,7 @@ module Resque
|
|
34
35
|
redis = Redis.new(:host => host, :port => port,
|
35
36
|
:thread_safe => true, :db => db)
|
36
37
|
@redis = Redis::Namespace.new(:resque, :redis => redis)
|
37
|
-
when Redis, Redis::Client
|
38
|
+
when Redis, Redis::Client, Redis::DistRedis
|
38
39
|
@redis = Redis::Namespace.new(:resque, :redis => server)
|
39
40
|
when Redis::Namespace
|
40
41
|
@redis = server
|
@@ -3,23 +3,23 @@ module Resque
|
|
3
3
|
# A Failure backend that uses multiple backends
|
4
4
|
# delegates all queries to the first backend
|
5
5
|
class Multiple < Base
|
6
|
-
|
6
|
+
|
7
7
|
class << self
|
8
8
|
attr_accessor :classes
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def self.configure
|
12
12
|
yield self
|
13
13
|
Resque::Failure.backend = self
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def initialize(*args)
|
17
17
|
@backends = self.class.classes.map {|klass| klass.new(*args)}
|
18
18
|
end
|
19
19
|
def save
|
20
20
|
@backends.each(&:save)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
# The number of failures.
|
24
24
|
def self.count
|
25
25
|
classes.first.count
|
@@ -34,11 +34,15 @@ module Resque
|
|
34
34
|
def self.url
|
35
35
|
classes.first.url
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
# Clear all failure objects
|
39
39
|
def self.clear
|
40
40
|
classes.first.clear
|
41
41
|
end
|
42
|
+
|
43
|
+
def self.requeue(*args)
|
44
|
+
classes.first.requeue(*args)
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
@@ -35,8 +35,12 @@
|
|
35
35
|
<dd><code><%= job['exception'] %></code></dd>
|
36
36
|
<dt>Error</dt>
|
37
37
|
<dd class='error'>
|
38
|
-
|
39
|
-
|
38
|
+
<% if job['backtrace'] %>
|
39
|
+
<a href="#" class="backtrace"><%= h(job['error']) %></a>
|
40
|
+
<pre style='display:none'><%=h job['backtrace'].join("\n") %></pre>
|
41
|
+
<% else %>
|
42
|
+
<%=h job['error'] %>
|
43
|
+
<% end %>
|
40
44
|
</dd>
|
41
45
|
</dl>
|
42
46
|
<div class='r'>
|
data/lib/resque/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 8
|
8
|
+
- 1
|
9
|
+
version: 1.8.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Chris Wanstrath
|
@@ -9,59 +14,61 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-29 00:00:00 -07:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: redis
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
25
32
|
- !ruby/object:Gem::Dependency
|
26
33
|
name: redis-namespace
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
33
41
|
version: "0"
|
34
|
-
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
35
44
|
- !ruby/object:Gem::Dependency
|
36
45
|
name: vegas
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
prerelease: false
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
48
|
requirements:
|
41
49
|
- - ">="
|
42
50
|
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
- 1
|
54
|
+
- 2
|
43
55
|
version: 0.1.2
|
44
|
-
|
56
|
+
type: :runtime
|
57
|
+
version_requirements: *id003
|
45
58
|
- !ruby/object:Gem::Dependency
|
46
59
|
name: sinatra
|
47
|
-
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
prerelease: false
|
61
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
62
|
requirements:
|
51
63
|
- - ">="
|
52
64
|
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
- 9
|
68
|
+
- 2
|
53
69
|
version: 0.9.2
|
54
|
-
|
55
|
-
|
56
|
-
name: jeweler
|
57
|
-
type: :development
|
58
|
-
version_requirement:
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - ">="
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: "0"
|
64
|
-
version:
|
70
|
+
type: :runtime
|
71
|
+
version_requirements: *id004
|
65
72
|
description: " Resque is a Redis-backed Ruby library for creating background jobs,\n placing those jobs on multiple queues, and processing them later.\n\n Background jobs can be any Ruby class or module that responds to\n perform. Your existing classes can easily be converted to background\n jobs or you can create new classes specifically to do work. Or, you\n can do both.\n\n Resque is heavily inspired by DelayedJob (which rocks) and is\n comprised of three parts:\n\n * A Ruby library for creating, querying, and processing jobs\n * A Rake task for starting a worker which processes jobs\n * A Sinatra app for monitoring queues, jobs, and workers.\n"
|
66
73
|
email: chris@ozmm.org
|
67
74
|
executables:
|
@@ -73,42 +80,18 @@ extra_rdoc_files:
|
|
73
80
|
- LICENSE
|
74
81
|
- README.markdown
|
75
82
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .kick
|
78
|
-
- CONTRIBUTORS
|
79
|
-
- HISTORY.md
|
80
|
-
- LICENSE
|
81
83
|
- README.markdown
|
82
84
|
- Rakefile
|
83
|
-
-
|
84
|
-
- bin/resque-web
|
85
|
-
- config.ru
|
86
|
-
- deps.rip
|
87
|
-
- docs/HOOKS.md
|
88
|
-
- docs/PLUGINS.md
|
89
|
-
- examples/async_helper.rb
|
90
|
-
- examples/demo/README.markdown
|
91
|
-
- examples/demo/Rakefile
|
92
|
-
- examples/demo/app.rb
|
93
|
-
- examples/demo/config.ru
|
94
|
-
- examples/demo/job.rb
|
95
|
-
- examples/god/resque.god
|
96
|
-
- examples/god/stale.god
|
97
|
-
- examples/instance.rb
|
98
|
-
- examples/monit/resque.monit
|
99
|
-
- examples/simple.rb
|
100
|
-
- init.rb
|
101
|
-
- lib/resque.rb
|
85
|
+
- LICENSE
|
102
86
|
- lib/resque/errors.rb
|
103
|
-
- lib/resque/failure.rb
|
104
87
|
- lib/resque/failure/base.rb
|
105
88
|
- lib/resque/failure/hoptoad.rb
|
106
89
|
- lib/resque/failure/multiple.rb
|
107
90
|
- lib/resque/failure/redis.rb
|
91
|
+
- lib/resque/failure.rb
|
108
92
|
- lib/resque/helpers.rb
|
109
93
|
- lib/resque/job.rb
|
110
94
|
- lib/resque/plugin.rb
|
111
|
-
- lib/resque/server.rb
|
112
95
|
- lib/resque/server/public/idle.png
|
113
96
|
- lib/resque/server/public/jquery-1.3.2.min.js
|
114
97
|
- lib/resque/server/public/jquery.relatize_date.js
|
@@ -129,12 +112,14 @@ files:
|
|
129
112
|
- lib/resque/server/views/stats.erb
|
130
113
|
- lib/resque/server/views/workers.erb
|
131
114
|
- lib/resque/server/views/working.erb
|
115
|
+
- lib/resque/server.rb
|
132
116
|
- lib/resque/stat.rb
|
133
117
|
- lib/resque/tasks.rb
|
134
118
|
- lib/resque/version.rb
|
135
119
|
- lib/resque/worker.rb
|
136
|
-
-
|
137
|
-
-
|
120
|
+
- lib/resque.rb
|
121
|
+
- bin/resque
|
122
|
+
- bin/resque-web
|
138
123
|
- test/job_hooks_test.rb
|
139
124
|
- test/job_plugins_test.rb
|
140
125
|
- test/plugin_test.rb
|
@@ -144,7 +129,7 @@ files:
|
|
144
129
|
- test/test_helper.rb
|
145
130
|
- test/worker_test.rb
|
146
131
|
has_rdoc: true
|
147
|
-
homepage: http://github.com/defunkt/
|
132
|
+
homepage: http://github.com/defunkt/mustache
|
148
133
|
licenses: []
|
149
134
|
|
150
135
|
post_install_message:
|
@@ -156,31 +141,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
141
|
requirements:
|
157
142
|
- - ">="
|
158
143
|
- !ruby/object:Gem::Version
|
144
|
+
segments:
|
145
|
+
- 0
|
159
146
|
version: "0"
|
160
|
-
version:
|
161
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
148
|
requirements:
|
163
149
|
- - ">="
|
164
150
|
- !ruby/object:Gem::Version
|
151
|
+
segments:
|
152
|
+
- 0
|
165
153
|
version: "0"
|
166
|
-
version:
|
167
154
|
requirements: []
|
168
155
|
|
169
156
|
rubyforge_project:
|
170
|
-
rubygems_version: 1.3.
|
157
|
+
rubygems_version: 1.3.6
|
171
158
|
signing_key:
|
172
159
|
specification_version: 3
|
173
160
|
summary: Resque is a Redis-backed queueing system.
|
174
|
-
test_files:
|
175
|
-
|
176
|
-
- test/job_plugins_test.rb
|
177
|
-
- test/plugin_test.rb
|
178
|
-
- test/resque-web_test.rb
|
179
|
-
- test/resque_test.rb
|
180
|
-
- test/test_helper.rb
|
181
|
-
- test/worker_test.rb
|
182
|
-
- examples/async_helper.rb
|
183
|
-
- examples/demo/app.rb
|
184
|
-
- examples/demo/job.rb
|
185
|
-
- examples/instance.rb
|
186
|
-
- examples/simple.rb
|
161
|
+
test_files: []
|
162
|
+
|
data/.gitignore
DELETED
data/.kick
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# take control of the growl notifications
|
2
|
-
module GrowlHacks
|
3
|
-
def growl(type, subject, body, *args, &block)
|
4
|
-
case type
|
5
|
-
when Kicker::GROWL_NOTIFICATIONS[:succeeded]
|
6
|
-
puts subject = "Success"
|
7
|
-
body = body.split("\n").last
|
8
|
-
when Kicker::GROWL_NOTIFICATIONS[:failed]
|
9
|
-
subject = "Failure"
|
10
|
-
puts body
|
11
|
-
body = body.split("\n").last
|
12
|
-
else
|
13
|
-
return nil
|
14
|
-
end
|
15
|
-
super(type, subject, body, *args, &block)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
Kicker.send :extend, GrowlHacks
|
20
|
-
|
21
|
-
# no logging
|
22
|
-
Kicker::Utils.module_eval do
|
23
|
-
def log(message)
|
24
|
-
nil
|
25
|
-
end
|
26
|
-
end
|
data/CONTRIBUTORS
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
* Chris Wanstrath
|
2
|
-
* gravis
|
3
|
-
* scotttam
|
4
|
-
* John Barnette
|
5
|
-
* Mike Mangino
|
6
|
-
* Rob Hanlon
|
7
|
-
* Jason Amster
|
8
|
-
* Aaron Quint
|
9
|
-
* Adam Cooke
|
10
|
-
* Ashley Martens
|
11
|
-
* Matt Duncan
|
12
|
-
* Michael Dwan
|
13
|
-
* Daniel Ceballos
|
14
|
-
* Roman Heinrich
|
15
|
-
* Thibaut Barrère
|
16
|
-
* jgeiger
|
17
|
-
* Simon Rozet
|
18
|
-
* Dave Hoover
|
19
|
-
* Christos Trochalakis
|
20
|
-
* Ben VandenBos
|
21
|
-
* snusnu
|
22
|
-
* Arthur Zapparoli
|
23
|
-
* Ben Marini
|
24
|
-
* Brian P O'Rourke
|
25
|
-
* Jim Remsik and Les Hill
|
26
|
-
* Karel Minarik
|
27
|
-
* Luc Castera
|
28
|
-
* Masatomo Nakano
|
29
|
-
* Matt Palmer
|
30
|
-
* PJ Hyett
|
31
|
-
* Roland Moriz
|
32
|
-
* malomalo
|
data/HISTORY.md
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
## 1.8.0 (2010-04-07)
|
2
|
-
|
3
|
-
* Jobs that never complete due to killed worker are now failed.
|
4
|
-
* Worker "working" state is now maintained by the parent, not the child.
|
5
|
-
* Stopped using deprecated redis.rb methods
|
6
|
-
* `Worker.working` race condition fixed
|
7
|
-
* `Worker#process` has been deprecated.
|
8
|
-
* Monit example fixed
|
9
|
-
* Redis::Client and Redis::Namespace can be passed to `Resque.redis=`
|
10
|
-
|
11
|
-
## 1.7.1 (2010-04-02)
|
12
|
-
|
13
|
-
* Bugfix: Make job hook execution order consistent
|
14
|
-
* Bugfix: stdout buffering in child process
|
15
|
-
|
16
|
-
## 1.7.0 (2010-03-31)
|
17
|
-
|
18
|
-
* Job hooks API. See docs/HOOKS.md.
|
19
|
-
* web: Hovering over dates shows a timestamp
|
20
|
-
* web: AJAXify retry action for failed jobs
|
21
|
-
* web bugfix: Fix pagination bug
|
22
|
-
|
23
|
-
## 1.6.1 (2010-03-25)
|
24
|
-
|
25
|
-
* Bugfix: Workers may not be clearing their state correctly on
|
26
|
-
shutdown
|
27
|
-
* Added example monit config.
|
28
|
-
* Exception class is now recorded when an error is raised in a
|
29
|
-
worker.
|
30
|
-
* web: Unit tests
|
31
|
-
* web: Show namespace in header and footer
|
32
|
-
* web: Remove a queue
|
33
|
-
* web: Retry failed jobs
|
34
|
-
|
35
|
-
## 1.6.0 (2010-03-09)
|
36
|
-
|
37
|
-
* Added `before_first_fork`, `before_fork`, and `after_fork` hooks.
|
38
|
-
* Hoptoad: Added server_environment config setting
|
39
|
-
* Hoptoad bugfix: Don't depend on RAILS_ROOT
|
40
|
-
* 1.8.6 compat fixes
|
41
|
-
|
42
|
-
## 1.5.2 (2010-03-03)
|
43
|
-
|
44
|
-
* Bugfix: JSON check was crazy.
|
45
|
-
|
46
|
-
## 1.5.1 (2010-03-03)
|
47
|
-
|
48
|
-
* `Job.destroy` and `Resque.dequeue` return the # of destroyed jobs.
|
49
|
-
* Hoptoad notifier improvements
|
50
|
-
* Specify the namespace with `resque-web` by passing `-N namespace`
|
51
|
-
* Bugfix: Don't crash when trying to parse invalid JSON.
|
52
|
-
* Bugfix: Non-standard namespace support
|
53
|
-
* Web: Red backgound for queue "failed" only shown if there are failed jobs.
|
54
|
-
* Web bugfix: Tabs highlight properly now
|
55
|
-
* Web bugfix: ZSET partial support in stats
|
56
|
-
* Web bugfix: Deleting failed jobs works again
|
57
|
-
* Web bugfix: Sets (or zsets, lists, etc) now paginate.
|
58
|
-
|
59
|
-
## 1.5.0 (2010-02-17)
|
60
|
-
|
61
|
-
* Version now included in procline, e.g. `resque-1.5.0: Message`
|
62
|
-
* Web bugfix: Ignore idle works in the "working" page
|
63
|
-
* Added `Resque::Job.destroy(queue, klass, *args)`
|
64
|
-
* Added `Resque.dequeue(klass, *args)`
|
65
|
-
|
66
|
-
## 1.4.0 (2010-02-11)
|
67
|
-
|
68
|
-
* Fallback when unable to bind QUIT and USR1 for Windows and JRuby.
|
69
|
-
* Fallback when no `Kernel.fork` is provided (for IronRuby).
|
70
|
-
* Web: Rounded corners in Firefox
|
71
|
-
* Cut down system calls in `Worker#prune_dead_workers`
|
72
|
-
* Enable switching DB in a Redis server from config
|
73
|
-
* Support USR2 and CONT to stop and start job processing.
|
74
|
-
* Web: Add example failing job
|
75
|
-
* Bugfix: `Worker#unregister_worker` shouldn't call `done_working`
|
76
|
-
* Bugfix: Example god config now restarts Resque properly.
|
77
|
-
* Multiple failure backends now permitted.
|
78
|
-
* Hoptoad failure backend updated to new API
|
79
|
-
|
80
|
-
## 1.3.1 (2010-01-11)
|
81
|
-
|
82
|
-
* Vegas bugfix: Don't error without a config
|
83
|
-
|
84
|
-
## 1.3.0 (2010-01-11)
|
85
|
-
|
86
|
-
* Use Vegas for resque-web
|
87
|
-
* Web Bugfix: Show proper date/time value for failed_at on Failures
|
88
|
-
* Web Bugfix: Make the / route more flexible
|
89
|
-
* Add Resque::Server.tabs array (so plugins can add their own tabs)
|
90
|
-
* Start using [Semantic Versioning](http://semver.org/)
|
91
|
-
|
92
|
-
## 1.2.4 (2009-12-15)
|
93
|
-
|
94
|
-
* Web Bugfix: fix key links on stat page
|
95
|
-
|
96
|
-
## 1.2.3 (2009-12-15)
|
97
|
-
|
98
|
-
* Bugfix: Fixed `rand` seeding in child processes.
|
99
|
-
* Bugfix: Better JSON encoding/decoding without Yajl.
|
100
|
-
* Bugfix: Avoid `ps` flag error on Linux
|
101
|
-
* Add `PREFIX` observance to `rake` install tasks.
|
102
|
-
|
103
|
-
## 1.2.2 (2009-12-08)
|
104
|
-
|
105
|
-
* Bugfix: Job equality was not properly implemented.
|
106
|
-
|
107
|
-
## 1.2.1 (2009-12-07)
|
108
|
-
|
109
|
-
* Added `rake resque:workers` task for starting multiple workers.
|
110
|
-
* 1.9.x compatibility
|
111
|
-
* Bugfix: Yajl decoder doesn't care about valid UTF-8
|
112
|
-
* config.ru loads RESQUECONFIG if the ENV variable is set.
|
113
|
-
* `resque-web` now sets RESQUECONFIG
|
114
|
-
* Job objects know if they are equal.
|
115
|
-
* Jobs can be re-queued using `Job#recreate`
|
116
|
-
|
117
|
-
## 1.2.0 (2009-11-25)
|
118
|
-
|
119
|
-
* If USR1 is sent and no child is found, shutdown.
|
120
|
-
* Raise when a job class does not respond to `perform`.
|
121
|
-
* Added `Resque.remove_queue` for deleting a queue
|
122
|
-
|
123
|
-
## 1.1.0 (2009-11-04)
|
124
|
-
|
125
|
-
* Bugfix: Broken ERB tag in failure UI
|
126
|
-
* Bugfix: Save the worker's ID, not the worker itself, in the failure module
|
127
|
-
* Redesigned the sinatra web interface
|
128
|
-
* Added option to clear failed jobs
|
129
|
-
|
130
|
-
## 1.0.0 (2009-11-03)
|
131
|
-
|
132
|
-
* First release.
|
data/config.ru
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'logger'
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift ::File.expand_path(::File.dirname(__FILE__) + '/lib')
|
5
|
-
require 'resque/server'
|
6
|
-
|
7
|
-
# Set the RESQUECONFIG env variable if you've a `resque.rb` or similar
|
8
|
-
# config file you want loaded on boot.
|
9
|
-
if ENV['RESQUECONFIG'] && ::File.exists?(::File.expand_path(ENV['RESQUECONFIG']))
|
10
|
-
load ::File.expand_path(ENV['RESQUECONFIG'])
|
11
|
-
end
|
12
|
-
|
13
|
-
use Rack::ShowExceptions
|
14
|
-
run Resque::Server.new
|
data/deps.rip
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
git://github.com/ezmobius/redis-rb.git eed200ad
|
2
|
-
git://github.com/brianmario/yajl-ruby.git 0.6.3
|
3
|
-
git://github.com/sinatra/sinatra.git 0.9.4
|
4
|
-
git://github.com/rack/rack.git 1.0
|
5
|
-
git://github.com/quirkey/vegas.git v0.1.2
|
6
|
-
git://github.com/brynary/rack-test.git v0.5.3
|
7
|
-
rake
|
data/docs/HOOKS.md
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
Resque Hooks
|
2
|
-
============
|
3
|
-
|
4
|
-
You can customize Resque or write plugins using its hook API. In many
|
5
|
-
cases you can use a hook rather than mess with Resque's internals.
|
6
|
-
|
7
|
-
For a list of available plugins see
|
8
|
-
<http://wiki.github.com/defunkt/resque/plugins>.
|
9
|
-
|
10
|
-
|
11
|
-
Worker Hooks
|
12
|
-
------------
|
13
|
-
|
14
|
-
If you wish to have a Proc called before the worker forks for the
|
15
|
-
first time, you can add it in the initializer like so:
|
16
|
-
|
17
|
-
Resque.before_first_fork do
|
18
|
-
puts "Call me once before the worker forks the first time"
|
19
|
-
end
|
20
|
-
|
21
|
-
You can also run a hook before _every_ fork:
|
22
|
-
|
23
|
-
Resque.before_fork do |job|
|
24
|
-
puts "Call me before the worker forks"
|
25
|
-
end
|
26
|
-
|
27
|
-
The `before_fork` hook will be run in the **parent** process. So, be
|
28
|
-
careful - any changes you make will be permanent for the lifespan of
|
29
|
-
the worker.
|
30
|
-
|
31
|
-
And after forking:
|
32
|
-
|
33
|
-
Resque.after_fork do |job|
|
34
|
-
puts "Call me after the worker forks"
|
35
|
-
end
|
36
|
-
|
37
|
-
The `after_fork` hook will be run in the child process and is passed
|
38
|
-
the current job. Any changes you make, therefor, will only live as
|
39
|
-
long as the job currently being processes.
|
40
|
-
|
41
|
-
All worker hooks can also be set using a setter, e.g.
|
42
|
-
|
43
|
-
Resque.after_fork = proc { puts "called" }
|
44
|
-
|
45
|
-
|
46
|
-
Job Hooks
|
47
|
-
---------
|
48
|
-
|
49
|
-
Plugins can utilize job hooks to provide additional behavior. A job
|
50
|
-
hook is a method name in the following format:
|
51
|
-
|
52
|
-
HOOKNAME_IDENTIFIER
|
53
|
-
|
54
|
-
For example, a `before_perform` hook which adds locking may be defined
|
55
|
-
like this:
|
56
|
-
|
57
|
-
def before_perform_with_lock(*args)
|
58
|
-
set_lock!
|
59
|
-
end
|
60
|
-
|
61
|
-
Once this hook is made available to your job (either by way of
|
62
|
-
inheritence or `extend`), it will be run before the job's `perform`
|
63
|
-
method is called. Hooks of each type are executed in alphabetical order,
|
64
|
-
so `before_perform_a` will always be executed before `before_perform_b`.
|
65
|
-
An unnamed hook (`before_perform`) will be executed first.
|
66
|
-
|
67
|
-
The available hooks are:
|
68
|
-
|
69
|
-
* `before_perform`: Called with the job args before perform. If it raises
|
70
|
-
`Resque::Job::DontPerform`, the job is aborted. If other exceptions
|
71
|
-
are raised, they will be propagated up the the `Resque::Failure`
|
72
|
-
backend.
|
73
|
-
|
74
|
-
* `after_perform`: Called with the job args after it performs. Uncaught
|
75
|
-
exceptions will propagate up to the `Resque::Failure` backend.
|
76
|
-
|
77
|
-
* `around_perform`: Called with the job args. It is expected to yield in order
|
78
|
-
to perform the job (but is not required to do so). It may handle exceptions
|
79
|
-
thrown by `perform`, but any that are not caught will propagate up to the
|
80
|
-
`Resque::Failure` backend.
|
81
|
-
|
82
|
-
* `on_failure`: Called with the exception and job args if any exception occurs
|
83
|
-
while performing the job (or hooks).
|
84
|
-
|
85
|
-
Hooks are easily implemented with superclasses or modules. A superclass could
|
86
|
-
look something like this.
|
87
|
-
|
88
|
-
class LoggedJob
|
89
|
-
def self.before_perform_log_job(*args)
|
90
|
-
Logger.info "About to perform #{self} with #{args.inspect}"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
class MyJob < LoggedJob
|
95
|
-
def self.perform(*args)
|
96
|
-
...
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
Modules are even better because jobs can use many of them.
|
101
|
-
|
102
|
-
module LoggedJob
|
103
|
-
def before_perform_log_job(*args)
|
104
|
-
Logger.info "About to perform #{self} with #{args.inspect}"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
module RetriedJob
|
109
|
-
def on_failure_retry(e, *args)
|
110
|
-
Logger.info "Performing #{self} caused an exception (#{e}). Retrying..."
|
111
|
-
Resque.enqueue self, *args
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
class MyJob
|
116
|
-
extend LoggedJob
|
117
|
-
extend RetriedJob
|
118
|
-
def self.perform(*args)
|
119
|
-
...
|
120
|
-
end
|
121
|
-
end
|
data/docs/PLUGINS.md
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
Resque Plugins
|
2
|
-
==============
|
3
|
-
|
4
|
-
Resque encourages plugin development. For a list of available plugins,
|
5
|
-
please see <http://wiki.github.com/defunkt/resque/plugins>.
|
6
|
-
|
7
|
-
The `docs/HOOKS.md` file included with Resque documents the available
|
8
|
-
hooks you can use to add or change Resque functionality. This document
|
9
|
-
describes best practice for plugins themselves.
|
10
|
-
|
11
|
-
|
12
|
-
Version
|
13
|
-
-------
|
14
|
-
|
15
|
-
Plugins should declare the major.minor version of Resque they are
|
16
|
-
known to work with explicitly in their README.
|
17
|
-
|
18
|
-
For example, if your plugin depends on features in Resque 2.1, please
|
19
|
-
list "Depends on Resque 2.1" very prominently near the beginning of
|
20
|
-
your README.
|
21
|
-
|
22
|
-
Because Resque uses [Semantic Versioning][sv], you can safely make the
|
23
|
-
following assumptions:
|
24
|
-
|
25
|
-
* Your plugin will work with 2.2, 2.3, etc - no methods will be
|
26
|
-
removed or changed, only added.
|
27
|
-
* Your plugin might not work with 3.0+, as APIs may change or be
|
28
|
-
removed.
|
29
|
-
|
30
|
-
|
31
|
-
Namespace
|
32
|
-
---------
|
33
|
-
|
34
|
-
All plugins should live under the `Resque::Plugins` module to avoid
|
35
|
-
clashing with first class Resque constants or other Ruby libraries.
|
36
|
-
|
37
|
-
Good:
|
38
|
-
|
39
|
-
* Resque::Plugins::Lock
|
40
|
-
* Resque::Plugins::FastRetry
|
41
|
-
|
42
|
-
Bad:
|
43
|
-
|
44
|
-
* Resque::Lock
|
45
|
-
* ResqueQueue
|
46
|
-
|
47
|
-
|
48
|
-
Gem Name
|
49
|
-
--------
|
50
|
-
|
51
|
-
Gem names should be in the format of `resque-FEATURE`, where `FEATURE`
|
52
|
-
succinctly describes the feature your plugin adds to Resque.
|
53
|
-
|
54
|
-
Good:
|
55
|
-
|
56
|
-
* resque-status
|
57
|
-
* resque-scheduler
|
58
|
-
|
59
|
-
Bad:
|
60
|
-
|
61
|
-
* multi-queue
|
62
|
-
* defunkt-resque-lock
|
63
|
-
|
64
|
-
|
65
|
-
Hooks
|
66
|
-
-----
|
67
|
-
|
68
|
-
Job hook names should be namespaced to work properly.
|
69
|
-
|
70
|
-
Good:
|
71
|
-
|
72
|
-
* before_perform_lock
|
73
|
-
* around_perform_check_status
|
74
|
-
|
75
|
-
Bad:
|
76
|
-
|
77
|
-
* before_perform
|
78
|
-
* on_failure
|
79
|
-
|
80
|
-
|
81
|
-
Lint
|
82
|
-
----
|
83
|
-
|
84
|
-
Plugins should test compliance to this document using the
|
85
|
-
`Resque::Plugin.lint` method.
|
86
|
-
|
87
|
-
For example:
|
88
|
-
|
89
|
-
assert_nothing_raised do
|
90
|
-
Resque::Plugin.lint(Resque::Plugins::Lock)
|
91
|
-
end
|
92
|
-
|
93
|
-
[sv]: http://semver.org/
|
data/examples/async_helper.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# If you want to just call a method on an object in the background,
|
2
|
-
# we can easily add that functionality to Resque.
|
3
|
-
#
|
4
|
-
# This is similar to DelayedJob's `send_later`.
|
5
|
-
#
|
6
|
-
# Keep in mind that, unlike DelayedJob, only simple Ruby objects
|
7
|
-
# can be persisted.
|
8
|
-
#
|
9
|
-
# If it can be represented in JSON, it can be stored in a job.
|
10
|
-
|
11
|
-
# Here's our ActiveRecord class
|
12
|
-
class Repository < ActiveRecord::Base
|
13
|
-
# This will be called by a worker when a job needs to be processed
|
14
|
-
def self.perform(id, method, *args)
|
15
|
-
find(id).send(method, *args)
|
16
|
-
end
|
17
|
-
|
18
|
-
# We can pass this any Repository instance method that we want to
|
19
|
-
# run later.
|
20
|
-
def async(method, *args)
|
21
|
-
Resque.enqueue(Repository, id, method, *args)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# Now we can call any method and have it execute later:
|
26
|
-
|
27
|
-
@repo.async(:update_disk_usage)
|
28
|
-
|
29
|
-
# or
|
30
|
-
|
31
|
-
@repo.async(:update_network_source_id, 34)
|
@@ -1,71 +0,0 @@
|
|
1
|
-
Resque Demo
|
2
|
-
-----------
|
3
|
-
|
4
|
-
This is a dirt simple Resque setup for you to play with.
|
5
|
-
|
6
|
-
|
7
|
-
### Starting the Demo App
|
8
|
-
|
9
|
-
Here's how to run the Sinatra app:
|
10
|
-
|
11
|
-
$ git clone git://github.com/defunkt/resque.git
|
12
|
-
$ cd resque/examples/demo
|
13
|
-
$ rackup config.ru
|
14
|
-
$ open http://localhost:9292/
|
15
|
-
|
16
|
-
Click 'Create New Job' a few times. You should see the number of
|
17
|
-
pending jobs rising.
|
18
|
-
|
19
|
-
|
20
|
-
### Starting the Demo Worker
|
21
|
-
|
22
|
-
Now in another shell terminal start the worker:
|
23
|
-
|
24
|
-
$ cd resque/examples/demo
|
25
|
-
$ VERBOSE=true QUEUE=default rake resque:work
|
26
|
-
|
27
|
-
You should see the following output:
|
28
|
-
|
29
|
-
*** Starting worker hostname:90185:default
|
30
|
-
*** got: (Job{default} | Demo::Job | [{}])
|
31
|
-
Processed a job!
|
32
|
-
*** done: (Job{default} | Demo::Job | [{}])
|
33
|
-
|
34
|
-
You can also use `VVERBOSE` (very verbose) if you want to see more:
|
35
|
-
|
36
|
-
$ VERBOSE=true QUEUE=default rake resque:work
|
37
|
-
*** Starting worker hostname:90399:default
|
38
|
-
** [05:55:09 2009-09-16] 90399: Registered signals
|
39
|
-
** [05:55:09 2009-09-16] 90399: Checking default
|
40
|
-
** [05:55:09 2009-09-16] 90399: Found job on default
|
41
|
-
** [05:55:09 2009-09-16] 90399: got: (Job{default} | Demo::Job | [{}])
|
42
|
-
** [05:55:09 2009-09-16] 90399: resque: Forked 90401 at 1253141709
|
43
|
-
** [05:55:09 2009-09-16] 90401: resque: Processing default since 1253141709
|
44
|
-
Processed a job!
|
45
|
-
** [05:55:10 2009-09-16] 90401: done: (Job{default} | Demo::Job | [{}])
|
46
|
-
|
47
|
-
Notice that our workers `require 'job'` in our `Rakefile`. This
|
48
|
-
ensures they have our app loaded and can access the job classes.
|
49
|
-
|
50
|
-
|
51
|
-
### Starting the Resque frontend
|
52
|
-
|
53
|
-
Great, now let's check out the Resque frontend. Either click on 'View
|
54
|
-
Resque' in your web browser or run:
|
55
|
-
|
56
|
-
$ open http://localhost:9292/resque/
|
57
|
-
|
58
|
-
You should see the Resque web frontend. 404 page? Don't forget the
|
59
|
-
trailing slash!
|
60
|
-
|
61
|
-
|
62
|
-
### config.ru
|
63
|
-
|
64
|
-
The `config.ru` shows you how to mount multiple Rack apps. Resque
|
65
|
-
should work fine on a subpath - feel free to load it up in your
|
66
|
-
Passenger app and protect it with some basic auth.
|
67
|
-
|
68
|
-
|
69
|
-
### That's it!
|
70
|
-
|
71
|
-
Click around, add some more queues, add more jobs, do whatever, have fun.
|
data/examples/demo/Rakefile
DELETED
data/examples/demo/app.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'sinatra/base'
|
2
|
-
require 'resque'
|
3
|
-
require 'job'
|
4
|
-
|
5
|
-
module Demo
|
6
|
-
class App < Sinatra::Base
|
7
|
-
get '/' do
|
8
|
-
info = Resque.info
|
9
|
-
out = "<html><head><title>Resque Demo</title></head><body>"
|
10
|
-
out << "<p>"
|
11
|
-
out << "There are #{info[:pending]} pending and "
|
12
|
-
out << "#{info[:processed]} processed jobs across #{info[:queues]} queues."
|
13
|
-
out << "</p>"
|
14
|
-
out << '<form method="POST">'
|
15
|
-
out << '<input type="submit" value="Create New Job"/>'
|
16
|
-
out << ' <a href="/resque/">View Resque</a>'
|
17
|
-
out << '</form>'
|
18
|
-
|
19
|
-
out << "<form action='/failing' method='POST''>"
|
20
|
-
out << '<input type="submit" value="Create Failing New Job"/>'
|
21
|
-
out << ' <a href="/resque/">View Resque</a>'
|
22
|
-
out << '</form>'
|
23
|
-
|
24
|
-
out << "</body></html>"
|
25
|
-
out
|
26
|
-
end
|
27
|
-
|
28
|
-
post '/' do
|
29
|
-
Resque.enqueue(Job, params)
|
30
|
-
redirect "/"
|
31
|
-
end
|
32
|
-
|
33
|
-
post '/failing' do
|
34
|
-
Resque.enqueue(FailingJob, params)
|
35
|
-
redirect "/"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
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'
|
data/tasks/redis.rake
DELETED
@@ -1,159 +0,0 @@
|
|
1
|
-
# Inspired by rabbitmq.rake the Redbox project at http://github.com/rick/redbox/tree/master
|
2
|
-
require 'fileutils'
|
3
|
-
require 'open-uri'
|
4
|
-
require 'pathname'
|
5
|
-
|
6
|
-
class RedisRunner
|
7
|
-
|
8
|
-
def self.redis_dir
|
9
|
-
@redis_dir ||= if ENV['PREFIX']
|
10
|
-
Pathname.new(ENV['PREFIX'])
|
11
|
-
else
|
12
|
-
Pathname.new(`which redis-server`) + '..' + '..'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.bin_dir
|
17
|
-
redis_dir + 'bin'
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.config
|
21
|
-
@config ||= if File.exists?(redis_dir + 'etc/redis.conf')
|
22
|
-
redis_dir + 'etc/redis.conf'
|
23
|
-
else
|
24
|
-
redis_dir + '../etc/redis.conf'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.dtach_socket
|
29
|
-
'/tmp/redis.dtach'
|
30
|
-
end
|
31
|
-
|
32
|
-
# Just check for existance of dtach socket
|
33
|
-
def self.running?
|
34
|
-
File.exists? dtach_socket
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.start
|
38
|
-
puts 'Detach with Ctrl+\ Re-attach with rake redis:attach'
|
39
|
-
sleep 1
|
40
|
-
command = "#{bin_dir}/dtach -A #{dtach_socket} #{bin_dir}/redis-server #{config}"
|
41
|
-
sh command
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.attach
|
45
|
-
exec "#{bin_dir}/dtach -a #{dtach_socket}"
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.stop
|
49
|
-
sh 'echo "SHUTDOWN" | nc localhost 6379'
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
namespace :redis do
|
55
|
-
|
56
|
-
desc 'About redis'
|
57
|
-
task :about do
|
58
|
-
puts "\nSee http://code.google.com/p/redis/ for information about redis.\n\n"
|
59
|
-
end
|
60
|
-
|
61
|
-
desc 'Start redis'
|
62
|
-
task :start do
|
63
|
-
RedisRunner.start
|
64
|
-
end
|
65
|
-
|
66
|
-
desc 'Stop redis'
|
67
|
-
task :stop do
|
68
|
-
RedisRunner.stop
|
69
|
-
end
|
70
|
-
|
71
|
-
desc 'Restart redis'
|
72
|
-
task :restart do
|
73
|
-
RedisRunner.stop
|
74
|
-
RedisRunner.start
|
75
|
-
end
|
76
|
-
|
77
|
-
desc 'Attach to redis dtach socket'
|
78
|
-
task :attach do
|
79
|
-
RedisRunner.attach
|
80
|
-
end
|
81
|
-
|
82
|
-
desc 'Install the latest verison of Redis from Github (requires git, duh)'
|
83
|
-
task :install => [:about, :download, :make] do
|
84
|
-
bin_dir = '/usr/bin'
|
85
|
-
conf_dir = '/etc'
|
86
|
-
|
87
|
-
if ENV['PREFIX']
|
88
|
-
bin_dir = "#{ENV['PREFIX']}/bin"
|
89
|
-
sh "mkdir -p #{bin_dir}" unless File.exists?("#{bin_dir}")
|
90
|
-
|
91
|
-
conf_dir = "#{ENV['PREFIX']}/etc"
|
92
|
-
sh "mkdir -p #{conf_dir}" unless File.exists?("#{conf_dir}")
|
93
|
-
end
|
94
|
-
|
95
|
-
%w(redis-benchmark redis-cli redis-server).each do |bin|
|
96
|
-
sh "cp /tmp/redis/#{bin} #{bin_dir}"
|
97
|
-
end
|
98
|
-
|
99
|
-
puts "Installed redis-benchmark, redis-cli and redis-server to #{bin_dir}"
|
100
|
-
|
101
|
-
unless File.exists?("#{conf_dir}/redis.conf")
|
102
|
-
sh "cp /tmp/redis/redis.conf #{conf_dir}/redis.conf"
|
103
|
-
puts "Installed redis.conf to #{conf_dir} \n You should look at this file!"
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
task :make do
|
108
|
-
sh "cd /tmp/redis && make clean"
|
109
|
-
sh "cd /tmp/redis && make"
|
110
|
-
end
|
111
|
-
|
112
|
-
desc "Download package"
|
113
|
-
task :download do
|
114
|
-
sh 'rm -rf /tmp/redis/' if File.exists?("/tmp/redis/.svn")
|
115
|
-
sh 'git clone git://github.com/antirez/redis.git /tmp/redis' unless File.exists?('/tmp/redis')
|
116
|
-
sh "cd /tmp/redis && git pull" if File.exists?("/tmp/redis/.git")
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
namespace :dtach do
|
122
|
-
|
123
|
-
desc 'About dtach'
|
124
|
-
task :about do
|
125
|
-
puts "\nSee http://dtach.sourceforge.net/ for information about dtach.\n\n"
|
126
|
-
end
|
127
|
-
|
128
|
-
desc 'Install dtach 0.8 from source'
|
129
|
-
task :install => [:about, :download, :make] do
|
130
|
-
|
131
|
-
bin_dir = "/usr/bin"
|
132
|
-
|
133
|
-
if ENV['PREFIX']
|
134
|
-
bin_dir = "#{ENV['PREFIX']}/bin"
|
135
|
-
sh "mkdir -p #{bin_dir}" unless File.exists?("#{bin_dir}")
|
136
|
-
end
|
137
|
-
|
138
|
-
sh "cp /tmp/dtach-0.8/dtach #{bin_dir}"
|
139
|
-
end
|
140
|
-
|
141
|
-
task :make do
|
142
|
-
sh 'cd /tmp/dtach-0.8/ && ./configure && make'
|
143
|
-
end
|
144
|
-
|
145
|
-
desc "Download package"
|
146
|
-
task :download do
|
147
|
-
unless File.exists?('/tmp/dtach-0.8.tar.gz')
|
148
|
-
require 'net/http'
|
149
|
-
|
150
|
-
url = 'http://downloads.sourceforge.net/project/dtach/dtach/0.8/dtach-0.8.tar.gz'
|
151
|
-
open('/tmp/dtach-0.8.tar.gz', 'wb') do |file| file.write(open(url).read) end
|
152
|
-
end
|
153
|
-
|
154
|
-
unless File.directory?('/tmp/dtach-0.8')
|
155
|
-
sh 'cd /tmp && tar xzf dtach-0.8.tar.gz'
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
data/tasks/resque.rake
DELETED