resque-pool 0.6.0 → 0.7.0

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
- metadata.gz: 88e5c211d7bdebea532f4d75cc7cb8772315ec83
4
- data.tar.gz: d137b2d808b9fae0bedf4b88436a844fe44e4bb5
3
+ metadata.gz: e5a0aca3c74178395af21e6f7ddde9add5784556
4
+ data.tar.gz: 9e7b1cc2747b3b82760b2aa637411fd841712ca8
5
5
  SHA512:
6
- metadata.gz: 6c818659ddf5e996358875d48ed2bb7b7aa9e4a987fd4f8752e2277694aa422319bceb89d01d1f8952148d1e2239ddd21fff0510eeea5bcc4b661610b8cd2e57
7
- data.tar.gz: 0c401f1af699ccb20833336bbcc12d05e22c9a629cdee1ac47573710b7e81d7bf186d3301c7d499cde21fa77502f00a9999f79935487fb89f42e893de50654b8
6
+ metadata.gz: d1f568bbd72acb8b1e7d1312222847b5a67d1b77fe95a56d0a8ae935064d20ba4e29a423dc8c6e5b724ae722745a3c57dc4e7ec81efd6d372ae810f028a9b8bf
7
+ data.tar.gz: f4b7118fc2cad3e95de6335bb5131525fc9a3af9ece1e817a423011437fc0558f17ee98b29ad0adf2fff6e516908ee7a3dae05d2d36bd198f4b064307e0f119a
@@ -0,0 +1,9 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ *.log
5
+ *.pid
6
+ examples/tmp/*
7
+ tmp/*
8
+ vendor
9
+ tags
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ services: redis
5
+ rvm:
6
+ - 2.3.8
7
+ - 2.4.5
8
+ - 2.5.3
9
+ - 2.6.1
10
+
11
+ before_install:
12
+ - gem update --system
13
+ - gem install bundler
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at nick@ekenosen.net. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,23 @@
1
+ Contributing
2
+ ============
3
+
4
+ We gladly accept help and bugfixes for resque-pool. We follow the guidelines of
5
+ [semantic versioning](http://semver.org/) for all new gem releases.
6
+
7
+ Pull request guidelines
8
+ -----------------------
9
+
10
+ 1. Fork it and clone your new repo
11
+ 2. Create a branch (`git checkout -b my_awesome_feature`)
12
+ 3. Commit your changes (`git add my/awesome/file.rb; git commit -m "Added my awesome feature"`)
13
+ 4. Push your changes to your fork (`git push origin my_awesome_feature`)
14
+ 5. Open a [Pull Request](/nevans/resque-pool/pulls)
15
+
16
+ Pull requests should have automated test coverage.
17
+
18
+ New release policy
19
+ ------------------
20
+
21
+ New versions won't be released until a release candidate has been running in a
22
+ maintainer's production environment for at least a week. Exceptions only for
23
+ security-related patches.
@@ -1,3 +1,12 @@
1
+ ## 0.7.0 _unreleased_
2
+ [full changelog](https://github.com/nevans/resque-pool/compare/v0.6.0...master).
3
+
4
+ One big new feature: `--hot-swap` for [zero-downtime code
5
+ deploys](https://github.com/nevans/resque-pool#zero-downtime-code-deploys).
6
+ Thanks to [joshuaflanagan](https://github.com/joshuaflanagan),
7
+ [brasic](https://github.com/brasic), and
8
+ [ShippingEasy](https://github.com/ShippingEasy)!
9
+
1
10
  ## 0.6.0
2
11
  [full changelog](https://github.com/nevans/resque-pool/compare/v0.5.0...v0.6.0).
3
12
 
@@ -8,7 +17,7 @@ thanks to [joshuaflanagan](https://github.com/joshuaflanagan)!
8
17
  Lots of cleanup in this release. Thanks to the contributers:
9
18
 
10
19
  * [joshuaflanagan](https://github.com/joshuaflanagan) Custom config loader
11
- * [grosser](https://github/grosser)
20
+ * [grosser](https://github.com/grosser)
12
21
  * ship less files in the gem
13
22
  * remove trollop dependency
14
23
  * remove -n -t -r -n -i commandline options since they were added unintentionally
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,102 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ resque-pool (0.7.0)
5
+ rake (>= 10.0, < 13.0)
6
+ resque (>= 1.22, < 3)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ aruba (0.14.8)
12
+ childprocess (>= 0.6.3, < 1.1.0)
13
+ contracts (~> 0.9)
14
+ cucumber (>= 1.3.19)
15
+ ffi (~> 1.9)
16
+ rspec-expectations (>= 2.99)
17
+ thor (~> 0.19)
18
+ backports (3.12.0)
19
+ builder (3.2.3)
20
+ childprocess (1.0.1)
21
+ rake (< 13.0)
22
+ contracts (0.16.0)
23
+ cucumber (3.1.2)
24
+ builder (>= 2.1.2)
25
+ cucumber-core (~> 3.2.0)
26
+ cucumber-expressions (~> 6.0.1)
27
+ cucumber-wire (~> 0.0.1)
28
+ diff-lcs (~> 1.3)
29
+ gherkin (~> 5.1.0)
30
+ multi_json (>= 1.7.5, < 2.0)
31
+ multi_test (>= 0.1.2)
32
+ cucumber-core (3.2.1)
33
+ backports (>= 3.8.0)
34
+ cucumber-tag_expressions (~> 1.1.0)
35
+ gherkin (~> 5.0)
36
+ cucumber-expressions (6.0.1)
37
+ cucumber-tag_expressions (1.1.1)
38
+ cucumber-wire (0.0.1)
39
+ diff-lcs (1.3)
40
+ ffi (1.10.0)
41
+ gherkin (5.1.0)
42
+ hpricot (0.8.6)
43
+ mono_logger (1.1.0)
44
+ multi_json (1.13.1)
45
+ multi_test (0.1.2)
46
+ mustache (1.1.0)
47
+ mustermann (1.0.3)
48
+ rack (2.0.6)
49
+ rack-protection (2.0.5)
50
+ rack
51
+ rake (12.3.2)
52
+ rdiscount (2.2.0.1)
53
+ redis (4.1.0)
54
+ redis-namespace (1.6.0)
55
+ redis (>= 3.0.4)
56
+ resque (2.0.0)
57
+ mono_logger (~> 1.0)
58
+ multi_json (~> 1.0)
59
+ redis-namespace (~> 1.6)
60
+ sinatra (>= 0.9.2)
61
+ vegas (~> 0.1.2)
62
+ ronn (0.7.3)
63
+ hpricot (>= 0.8.2)
64
+ mustache (>= 0.7.0)
65
+ rdiscount (>= 1.5.8)
66
+ rspec (3.8.0)
67
+ rspec-core (~> 3.8.0)
68
+ rspec-expectations (~> 3.8.0)
69
+ rspec-mocks (~> 3.8.0)
70
+ rspec-core (3.8.0)
71
+ rspec-support (~> 3.8.0)
72
+ rspec-expectations (3.8.2)
73
+ diff-lcs (>= 1.2.0, < 2.0)
74
+ rspec-support (~> 3.8.0)
75
+ rspec-mocks (3.8.0)
76
+ diff-lcs (>= 1.2.0, < 2.0)
77
+ rspec-support (~> 3.8.0)
78
+ rspec-support (3.8.0)
79
+ sinatra (2.0.5)
80
+ mustermann (~> 1.0)
81
+ rack (~> 2.0)
82
+ rack-protection (= 2.0.5)
83
+ tilt (~> 2.0)
84
+ thor (0.20.3)
85
+ tilt (2.0.9)
86
+ vegas (0.1.11)
87
+ rack (>= 1.0.0)
88
+
89
+ PLATFORMS
90
+ ruby
91
+
92
+ DEPENDENCIES
93
+ aruba (~> 0.14.0)
94
+ bundler (~> 2.0)
95
+ cucumber (~> 3.0)
96
+ mustache
97
+ resque-pool!
98
+ ronn
99
+ rspec (~> 3.8)
100
+
101
+ BUNDLED WITH
102
+ 2.0.1
@@ -1,4 +1,6 @@
1
- Copyright (C) 2010 by Nicholas Evans <nick@ekenosen.net>, et al.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (C) 2019 by Nicholas Evans, and other contributors
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
6
  of this software and associated documentation files (the "Software"), to deal
@@ -17,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
21
  THE SOFTWARE.
20
-
data/README.md CHANGED
@@ -4,23 +4,23 @@ Resque Pool
4
4
  [![Build Status](https://travis-ci.org/nevans/resque-pool.png)](https://travis-ci.org/nevans/resque-pool)
5
5
  [![Dependency Status](https://gemnasium.com/nevans/resque-pool.png)](https://gemnasium.com/nevans/resque-pool)
6
6
 
7
- Resque pool is a simple library for managing a pool of
8
- [resque](https://github.com/defunkt/resque) workers. Given a a config file, it
9
- manages your workers for you, starting up the appropriate number of workers for
10
- each worker type.
7
+ Resque pool is a daemon for managing a pool of
8
+ [resque](https://github.com/defunkt/resque) workers. With a simple config file,
9
+ it manages your workers for you, starting up the appropriate number of workers
10
+ for each worker type.
11
11
 
12
12
  Benefits
13
13
  ---------
14
14
 
15
15
  * Less config - With a simple YAML file, you can start up a pool daemon, and it
16
- will monitor your workers for you. An example init.d script, monit config,
17
- and chef cookbook are provided.
18
- * Less memory - If you are using Ruby Enterprise Edition, or any ruby with
19
- copy-on-write safe garbage collection, this should save you a *lot* of memory
20
- when you are managing many workers.
16
+ will monitor your workers for you.
17
+ * Less memory - If you are using ruby 2.0+ (with copy-on-write safe garbage
18
+ collection), this should save you a *lot* of memory when you are managing many
19
+ workers.
21
20
  * Faster startup - when you start many workers at once, they would normally
22
- compete for CPU as they load their environments. Resque-pool can load the
23
- environment once and fork all of the workers almost instantly.
21
+ compete for CPU as they load their environments. Resque-pool can load your
22
+ application once, then rapidly fork the workers after setup. If a worker
23
+ crashes or is killed, a new worker will start up and take its place right away.
24
24
 
25
25
  Upgrading?
26
26
  -----------
@@ -80,7 +80,7 @@ end
80
80
  For normal work with fresh resque and resque-scheduler gems add next lines in lib/rake/resque.rake
81
81
 
82
82
  ```ruby
83
- task 'resque:pool:setup' do
83
+ task "resque:pool:setup" do
84
84
  Resque::Pool.after_prefork do |job|
85
85
  Resque.redis.client.reconnect
86
86
  end
@@ -164,7 +164,7 @@ For example, if you wanted to vary the number of worker processes based on a
164
164
  value stored in Redis, you could do something like:
165
165
 
166
166
  ```ruby
167
- task resque:pool:setup do
167
+ task "resque:pool:setup" do
168
168
  Resque::Pool.config_loader = lambda do |env|
169
169
  worker_count = Redis.current.get("pool_workers_#{env}").to_i
170
170
  {"queueA,queueB" => worker_count }
@@ -172,6 +172,17 @@ task resque:pool:setup do
172
172
  end
173
173
  ```
174
174
 
175
+ In order to query ActiveRecord, be sure establish the database connection:
176
+
177
+ ```ruby
178
+ task "resque:pool:setup" do
179
+ Resque::Pool.config_loader = lambda do |env|
180
+ ActiveRecord::Base.establish_connection
181
+ JobQueue.pluck(:name, :workers).to_h
182
+ end
183
+ end
184
+ ```
185
+
175
186
  The configuration loader's `#call` method will be invoked about once a second.
176
187
  This allows the configuration to constantly change, allowing you to scale the
177
188
  number of workers up or down based on different conditions.
@@ -180,14 +191,54 @@ returns. It can optionally implement a `#reset!` method, which will be invoked
180
191
  when the HUP signal is received, allowing the loader to flush its cache, or
181
192
  perform any other re-initialization.
182
193
 
194
+ You can reduce the frequency that your configuration loader is called by
195
+ wrapping it with `Resque::Pool::ConfigLoaders::Throttled` and specifying a time
196
+ (in seconds) to cache the previous value:
197
+
198
+ ```ruby
199
+ task "resque:pool:setup" do
200
+ redis_loader = lambda do |env|
201
+ worker_count = Redis.current.get("pool_workers_#{env}").to_i
202
+ { "queueA,queueB" => worker_count }
203
+ end
204
+
205
+ # calls through to redis_loader at most once per 10 seconds
206
+ Resque::Pool.config_loader = Resque::Pool::ConfigLoaders::Throttled.new(
207
+ redis_loader, period: 10
208
+ )
209
+ end
210
+ ```
211
+
212
+ See [the spec](spec/config_loaders/throttled_spec.rb) for more details.
213
+
214
+ Zero-downtime code deploys
215
+ --------------------------
216
+
217
+ In a production environment you will likely want to manage the daemon using a
218
+ process supervisor like `runit` or `god` or an init system like `systemd` or
219
+ `upstart`. Example configurations for some of these are included in the
220
+ `examples` directory. With these systems, `reload` typically sends a `HUP`
221
+ signal, which will reload the configuration but not application code. The
222
+ simplest way to make workers pick up new code after a deploy is to stop and
223
+ start the daemon. This will result in a period where new jobs are not being
224
+ processed.
225
+
226
+ To avoid this downtime, leave the old pool running and start a new pool with
227
+ `resque-pool --hot-swap`.
228
+
229
+ The `--hot-swap` flag will turn off pidfiles (so multiple pools can run at
230
+ once), enable a lock file (so your init system knows when the pool is running),
231
+ and shut down other pools _after_ the workers have started for this pool.
232
+ These behaviors can also be configured separately (see `resque-pool --help`).
233
+ The `upstart` configs in the `examples` directory demonstrate how to supervise a
234
+ daemonized pool with hot swap.
235
+
236
+ Please be aware that this approach uses more memory than a simple restart, since
237
+ two copies of the application code are loaded at once. _TODO: [#139](https://github.com/nevans/resque-pool/issues/139)_
238
+
183
239
  Other Features
184
240
  --------------
185
241
 
186
- An example chef cookbook is provided (and should Just Work at Engine Yard as
187
- is; just provide a `/data/#{app_name}/shared/config/resque-pool.yml` on your
188
- utility instances). Even if you don't use chef you can use the example init.d
189
- and monitrc erb templates in `examples/chef_cookbook/templates/default`.
190
-
191
242
  You can also start a pool manager via `rake resque:pool` or from a plain old
192
243
  ruby script by calling `Resque::Pool.run`.
193
244
 
@@ -197,6 +248,10 @@ their current job) if the manager process disappears before them.
197
248
  You can specify an alternate config file by setting the `RESQUE_POOL_CONFIG` or
198
249
  with the `--config` command line option.
199
250
 
251
+ See the `examples` directory for example `chef` cookbook and
252
+ `god` config. In the `chef` cookbook, you can also find example `init.d` and
253
+ `muninrc` templates (all very out of date, pull requests welcome).
254
+
200
255
  TODO
201
256
  -----
202
257
 
@@ -205,8 +260,4 @@ See [the TODO list](https://github.com/nevans/resque-pool/issues) at github issu
205
260
  Contributors
206
261
  -------------
207
262
 
208
- * John Schult (config file can be split by environment)
209
- * Stephen Celis (increased gemspec sanity)
210
- * Vincent Agnello, Robert Kamunyori, Paul Kauders; for pairing with me at
211
- B'more on Rails Open Source Hack Nights. :)
212
-
263
+ See [list of contributors on github](https://github.com/nevans/resque-pool/graphs/contributors) or [in the changelog](https://github.com/nevans/resque-pool/blob/master/Changelog.md)
data/Rakefile CHANGED
@@ -1,20 +1,17 @@
1
- require 'bundler/setup'
2
1
  require 'bundler/gem_tasks'
3
2
 
4
3
  # for loading the example config file in config/resque-pool.yml
5
4
  require 'resque/pool/tasks'
6
5
 
7
6
  require 'rspec/core/rake_task'
8
- RSpec::Core::RakeTask.new(:spec) do |t|
9
- t.rspec_opts = ["-c", "-f progress"]
10
- end
7
+ RSpec::Core::RakeTask.new(:spec)
11
8
 
12
9
  require 'cucumber/rake/task'
13
10
  Cucumber::Rake::Task.new(:features) do |c|
14
11
  c.profile = "rake"
15
12
  end
16
13
 
17
- task :default => [:spec, :features]
14
+ task :default => %i[spec features]
18
15
 
19
16
  rule(/\.[1-9]$/ => [proc { |tn| "#{tn}.ronn" }]) do |t|
20
17
  name = Resque::Pool.name.sub('::','-').upcase
@@ -22,7 +19,7 @@ rule(/\.[1-9]$/ => [proc { |tn| "#{tn}.ronn" }]) do |t|
22
19
 
23
20
  manual = '--manual "%s"' % name
24
21
  organization = '--organization "%s"' % version
25
- sh "ronn #{manual} #{organization} <#{t.source} >#{t.name}"
22
+ sh "bundle exec ronn #{manual} #{organization} <#{t.source} >#{t.name}"
26
23
  end
27
24
 
28
25
  file 'man/resque-pool.1'