resque-pool 0.0.12.0.alpha → 0.0.12.1.alpha

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/README.md CHANGED
@@ -87,9 +87,6 @@ return something like the following:
87
87
  rails 13876 13858 0 13:44 ? S 0:00 \_ resque-1.9.9: Forked 7485 at 1280343255
88
88
  rails 7485 13876 0 14:54 ? S 0:00 \_ resque-1.9.9: Processing bar since 1280343254
89
89
 
90
- An example startup script, which redirects STDOUT and STDERR and creates a pid
91
- file, is given in the examples directory.
92
-
93
90
  SIGNALS
94
91
  -------
95
92
 
@@ -109,14 +106,21 @@ Other Features
109
106
  --------------
110
107
 
111
108
  You can run resque-pool as a daemon via `--daemon`. It will default to placing
112
- the pidfile and logfiles in the rails default locations, so you may want to
113
- configure that. See `resque-pool --help` for more options. An example init.d
114
- script and monitrc are included, as erb templates.
109
+ the pidfile and logfiles in the rails default locations, and you may want to
110
+ configure that. See `resque-pool --help` for more options.
111
+
112
+ An example init.d script and monitrc are provided in
113
+ `examples/chef_cookbook/templates/default`, as erb templates. Just copy them
114
+ into place, filling in the erb variables as necessary. An example chef recipe
115
+ is also provided (it should work at Engine Yard as is; just provide a
116
+ `/data/#{app_name}/shared/config/resque-pool.yml` on your utility servers).
115
117
 
116
- You can also run `resque-pool` via the `resque:pool` rake task.
118
+ You can also run `resque-pool` via the `resque:pool` rake task or from a plain
119
+ old ruby script by calling `Resque::Pool.run`.
117
120
 
118
- Workers will watch the pool master, and gracefully shutdown if the master
119
- process dies (for whatever reason) before them.
121
+ Workers will watch the pool master, and gracefully shutdown (after completing
122
+ their current job) if the master process dies (for whatever reason) before
123
+ them.
120
124
 
121
125
  You can specify an alternate config file by setting the `RESQUE_POOL_CONFIG`
122
126
  environment variable like so:
@@ -128,14 +132,14 @@ TODO
128
132
 
129
133
  * cmd line option for non-rake loading
130
134
  * cmd line option for preload ruby file
131
- * perhaps provide Unix style log formatter
135
+ * provide Unix style log formatter
136
+ * web interface for adding and removing workers (etc)
132
137
  * recover gracefully from a malformed config file (on startup and HUP)
133
138
  * procline for malformed config file, graceful shutdown... and other states?
134
- * web interface for adding and removing workers (etc)
135
139
  * figure out a good automated way to test this (cucumber or rspec?)
136
- * rename to `resque-squad`?
137
140
  * clean up the code (I stole most of it from unicorn, and it's still a bit
138
141
  bastardized); excessive use of vim foldmarkers are a code smell.
142
+ * rename to `resque-squad`?
139
143
  * rdoc
140
144
  * incorporate resque-batchworker features? (v2.0)
141
145
 
@@ -143,3 +147,4 @@ Contributors
143
147
  -------------
144
148
 
145
149
  * John Schult (config file can be split by environment)
150
+ * Stephen Celis (increased gemspec sanity)
@@ -1,38 +1,40 @@
1
1
  if ['solo', 'util'].include?(node[:instance_role])
2
+ node[:applications].each do |app, data|
2
3
 
3
- template "/etc/monit.d/#{app}_resque.monitrc" do
4
- owner 'root'
5
- group 'root'
6
- mode 0644
7
- source "monitrc.erb"
8
- variables({
9
- :app_name => app,
10
- #:max_mem => "400 MB",
11
- })
12
- end
4
+ template "/etc/monit.d/#{app}_resque.monitrc" do
5
+ owner 'root'
6
+ group 'root'
7
+ mode 0644
8
+ source "monitrc.erb"
9
+ variables({
10
+ :app_name => app,
11
+ #:max_mem => "400 MB",
12
+ })
13
+ end
13
14
 
14
- template "/etc/init.d/#{app}_resque" do
15
- owner 'root'
16
- group 'root'
17
- mode 0744
18
- source "initd.rb"
19
- variables({
20
- :app_name => app,
21
- })
22
- end
15
+ template "/etc/init.d/#{app}_resque" do
16
+ owner 'root'
17
+ group 'root'
18
+ mode 0744
19
+ source "initd.rb"
20
+ variables({
21
+ :app_name => app,
22
+ })
23
+ end
23
24
 
24
- execute "enable-resque" do
25
- command "rc-update add #{app}_resque default"
26
- action :run
27
- not_if "rc-update show | grep -q #{app}_resque.*default"
28
- end
25
+ execute "enable-resque" do
26
+ command "rc-update add #{app}_resque default"
27
+ action :run
28
+ not_if "rc-update show | grep -q '^ *#{app}_resque |.*default"
29
+ end
29
30
 
30
- execute "start-resque" do
31
- command %Q{/etc/init.d/#{app}_resque start}
32
- end
31
+ execute "start-resque" do
32
+ command %Q{/etc/init.d/#{app}_resque start}
33
+ end
33
34
 
34
- execute "ensure-resque-is-setup-with-monit" do
35
- command %Q{monit reload}
36
- end
35
+ execute "ensure-resque-is-setup-with-monit" do
36
+ command %Q{monit reload}
37
+ end
37
38
 
39
+ end
38
40
  end
@@ -1,4 +1,5 @@
1
1
  require 'trollop'
2
+ require 'resque/pool'
2
3
 
3
4
  module Resque
4
5
  class Pool
@@ -16,7 +17,7 @@ module Resque
16
17
 
17
18
  def parse_options
18
19
  opts = Trollop::options do
19
- version "resque-pool #{Resque::Pool::VERSION} (c) nicholas a. evans"
20
+ version "resque-pool #{VERSION} (c) nicholas a. evans"
20
21
  banner <<-EOS
21
22
  resque-pool is the best way to manage a group (pool) of resque workers
22
23
 
@@ -33,13 +34,12 @@ where [options] are:
33
34
  opt :stderr, "Redirect stderr to logfile", :type => String, :short => '-e'
34
35
  opt :nosync, "Don't sync logfiles on every write"
35
36
  opt :pidfile, "PID file location", :type => String, :short => "-p"
36
- opt :environment, "Set RAILS_ENV/RACK_ENV/RESQUE_ENV",
37
- :default => "development", :short => "-E"
37
+ opt :environment, "Set RAILS_ENV/RACK_ENV/RESQUE_ENV", :type => String, :short => "-E"
38
38
  end
39
39
  if opts[:daemon]
40
40
  opts[:stdout] ||= "log/resque-pool.stdout.log"
41
41
  opts[:stderr] ||= "log/resque-pool.stderr.log"
42
- opts[:pidfile] ||= "resque-pool.pid"
42
+ opts[:pidfile] ||= "tmp/pids/resque-pool.pid"
43
43
  end
44
44
  opts
45
45
  end
@@ -77,14 +77,16 @@ where [options] are:
77
77
  end
78
78
 
79
79
  def setup_environment(opts)
80
- ENV["RACK_ENV"] = ENV["RAILS_ENV"] = ENV["RESQUE_ENV"] = opts[:environment]
81
- puts "Running in #{opts[:environment]} environment."
80
+ ENV["RACK_ENV"] = ENV["RAILS_ENV"] = ENV["RESQUE_ENV"] = opts[:environment] if opts[:environment]
81
+ puts "Resque Pool running in #{ENV["RAILS_ENV"] || "development"} environment."
82
82
  ENV["RESQUE_POOL_CONFIG"] = opts[:config] if opts[:config]
83
83
  end
84
84
 
85
85
  def start_pool
86
86
  require 'rake'
87
87
  require 'resque/pool/tasks'
88
+ Rake.application.init
89
+ Rake.application.load_rakefile
88
90
  Rake.application["resque:pool"].invoke
89
91
  end
90
92
 
@@ -1,5 +1,5 @@
1
1
  module Resque
2
2
  class Pool
3
- VERSION = "0.0.12.0.alpha"
3
+ VERSION = "0.0.12.1.alpha"
4
4
  end
5
5
  end
data/lib/resque/pool.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require 'resque'
3
+ require 'resque/pool/version'
3
4
  require 'resque/pool/logging'
4
5
  require 'resque/pool/pooled_worker'
5
6
  require 'fcntl'
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-pool
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1851332306
4
+ hash: -1851332310
5
5
  prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
9
  - 12
10
- - 0
10
+ - 1
11
11
  - alpha
12
- version: 0.0.12.0.alpha
12
+ version: 0.0.12.1.alpha
13
13
  platform: ruby
14
14
  authors:
15
15
  - nicholas a. evans