resque-forker 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,16 @@
1
- 2010-09-07 v1.2 Capistrano role is worker, not workers
1
+ 2010-09-16 v1.3 Show command in Resque console, USR1 dumps to syslog
2
+
3
+ Resque console now shows forker script command (look for 'script'). This will
4
+ help you determine which version is running, e.g. .../current/script/worker is
5
+ latest, whereas .../releases/20100916/script/worker will get stuck on this
6
+ release when you reload.
7
+
8
+ Experimental: send USR1 single to have Resque::Forker dump Resque statistics,
9
+ queue and worker lists to Syslog. You can then enjoy the glory of checking
10
+ status from the command line:
11
+
12
+ kill -USR1 <pid>
13
+ tail /var/log/syslog.log
2
14
 
3
15
  2010-09-06 v1.2 Capistrano task and script/trigger
4
16
 
data/README.rdoc CHANGED
@@ -79,7 +79,7 @@ master process, which will propagate them to all workers:
79
79
 
80
80
  kill -QUIT -- Quit gracefully
81
81
  kill -TERM -- Terminate immediately
82
- kill -USR1 -- Stop any ongoing job
82
+ kill -USR1 -- Dump status to syslog
83
83
  kill -USR2 -- Suspend worker
84
84
  kill -CONT -- Resume suspended worker
85
85
 
@@ -181,6 +181,15 @@ that doesn't have your regular account settings:
181
181
 
182
182
  $ env -i sudo /bin/bash --norc --noprofile
183
183
 
184
+ Also, make sure your script is running from the current directory. Say the
185
+ script path as shown in the Resque console is
186
+ /var/www/myapp/current/script/worker: reloading this script will load the most
187
+ recent version of your application.
188
+
189
+ On the other hand, if the script path looks like
190
+ /var/www/myapp/releases/20100916, reloading this script will reload the same
191
+ release over and over.
192
+
184
193
 
185
194
  == Credits
186
195
 
data/Rakefile CHANGED
@@ -26,3 +26,7 @@ end
26
26
  YARD::Rake::YardocTask.new do |doc|
27
27
  doc.files = FileList["lib/**/*.rb"]
28
28
  end
29
+
30
+ task :clobber do
31
+ rm_rf %w{doc .yardoc}
32
+ end
@@ -0,0 +1,16 @@
1
+ #!upstart
2
+ description "redis"
3
+
4
+ start on runlevel [2345]
5
+ stop on runlevel [06]
6
+
7
+ # Change this to your application's path
8
+ env RACK_ENV=production
9
+
10
+ # Using system Ruby
11
+ exec /var/www/app/current/script/workers
12
+ # Using system-wide RVM (assumes rvm wrapper <ver> app ruby)
13
+ # exec app_ruby /var/www/app/current/script/workers
14
+
15
+ respawn
16
+ normal exit 0 TERM QUIT
data/lib/resque/forker.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "logger"
2
2
  require "resque"
3
+ require "syslog"
3
4
 
4
5
  module Resque
5
6
  # Loading Rails, the application and all its dependencies takes significant time
@@ -62,6 +63,8 @@ module Resque
62
63
  # respawn
63
64
  class Forker
64
65
 
66
+ VERSION = "1.3.0"
67
+
65
68
  Options = Struct.new(:verbose, :very_verbose, :interval, :terminate)
66
69
 
67
70
  def initialize(options = nil)
@@ -133,7 +136,7 @@ module Resque
133
136
  exit
134
137
  end
135
138
  # Pause/continue processing
136
- trap(:USR1) { Process.kill :USR1, *@children }
139
+ trap(:USR1) { dump }
137
140
  trap(:USR2) { Process.kill :USR2, *@children }
138
141
  trap(:CONT) { Process.kill :CONT, *@children }
139
142
  # Reincarnate. Stop children, and reload binary (application and all)
@@ -203,6 +206,25 @@ module Resque
203
206
  exit!
204
207
  end
205
208
 
209
+ def dump
210
+ Syslog.open "resque-forker" unless Syslog.opened?
211
+ Syslog.notice "STATUS:"
212
+ for key, value in Resque.info.to_a.sort_by { |i| i[0].to_s }
213
+ Syslog.notice "%20s: %s" % [key, value]
214
+ end
215
+ Syslog.notice "QUEUES:"
216
+ for queue in Resque.queues.sort_by { |q| q.to_s }
217
+ Syslog.notice "%20s: %d" % [queue, Resque.size(queue)]
218
+ end
219
+ Syslog.notice "WORKERS:"
220
+ for worker in (workers = Resque.workers.sort_by { |w| w.to_s })
221
+ Syslog.notice "%40s: %s" % [worker, worker.state]
222
+ end
223
+ Syslog.notice "There are no registered workers" if workers.empty?
224
+ rescue
225
+ Syslog.err $!
226
+ end
227
+
206
228
  end
207
229
 
208
230
 
@@ -242,4 +264,13 @@ module Resque
242
264
  def fork!(options = nil)
243
265
  Resque::Forker.new(options).run
244
266
  end
267
+
268
+ # Have Resque console show the command/arguments.
269
+ alias :info_without_forker :info
270
+ def info
271
+ hash = info_without_forker
272
+ hash[:script] = ([$0] + ARGV).map { |a| a[/[\s"]/] ? a.inspect : a }.join(" ")
273
+ hash
274
+ end
275
+
245
276
  end
@@ -1,13 +1,17 @@
1
+ $: << File.dirname(__FILE__) + "/lib"
2
+ require "resque/forker"
3
+
1
4
  Gem::Specification.new do |spec|
2
5
  spec.name = "resque-forker"
3
- spec.version = "1.2.1"
6
+ spec.version = Resque::Forker::VERSION
4
7
  spec.author = "Assaf Arkin"
5
8
  spec.email = "assaf@labnotes.org"
6
9
  spec.homepage = "http://github.com/flowtown/resque-forker"
7
10
  spec.summary = "Super awesome forking action for Resque workers"
11
+ spec.description = "Use the power of forking to run multiple Resque workers."
8
12
  spec.post_install_message = ""
9
13
 
10
- spec.files = Dir["{lib,script}/**/*", "CHANGELOG", "MIT-LICENSE", "README.rdoc", "Rakefile", "*.gemspec"]
14
+ spec.files = Dir["{lib,script,etc}/**/*", "CHANGELOG", "MIT-LICENSE", "README.rdoc", "Rakefile", "*.gemspec"]
11
15
 
12
16
  spec.has_rdoc = true
13
17
  spec.extra_rdoc_files = "README.rdoc", "CHANGELOG"
data/script/workers CHANGED
@@ -25,3 +25,4 @@ Resque.before_first_fork do
25
25
  ActiveRecord::Base.establish_connection
26
26
  end
27
27
  Resque.fork!
28
+ puts "here"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-forker
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 2
9
- - 1
10
- version: 1.2.1
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Assaf Arkin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-07 00:00:00 -07:00
18
+ date: 2010-09-16 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: "0"
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
- description:
35
+ description: Use the power of forking to run multiple Resque workers.
36
36
  email: assaf@labnotes.org
37
37
  executables: []
38
38
 
@@ -46,6 +46,7 @@ files:
46
46
  - lib/resque/forker.rb
47
47
  - script/trigger
48
48
  - script/workers
49
+ - etc/init/workers.conf
49
50
  - CHANGELOG
50
51
  - MIT-LICENSE
51
52
  - README.rdoc
@@ -58,7 +59,7 @@ licenses: []
58
59
  post_install_message: ""
59
60
  rdoc_options:
60
61
  - --title
61
- - Resque Forker 1.2.1
62
+ - Resque Forker 1.3.0
62
63
  - --main
63
64
  - README.rdoc
64
65
  - --webcvs