resque-pool-vinted 0.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d55af35f8c657528df7c50b44e89ccf3eca71f61
4
+ data.tar.gz: 4ef8c5944dba41bec27ff0261659b500e719cc0a
5
+ SHA512:
6
+ metadata.gz: c4c664515d46859ba39ed51f31bf6c72e0d87399eb01e6091efac742ad7b6a148047d8053e787483b065967dd8ebe8a52af4ab1384a8fad34b38ffc160804d00
7
+ data.tar.gz: 9353984aadb57f4e865d82759a9ebc2296b4435066f3283f13438f1772abb4485396eb50054e482c992dd5d2bae998a32ce2ecb9868a55f7b0b90aea61421bd7
@@ -0,0 +1,77 @@
1
+ ## 0.4.0.dev (unreleased)
2
+
3
+ * ???
4
+
5
+ ## 0.3.0 (2012-05-22)
6
+
7
+ This is mostly just a long overdue maintenance release. Many pull requests were
8
+ merged. A few non-pull-request branches were merged too. This version supports
9
+ ruby 1.9.3, 1.8.7, and even ancient 1.8.6, and all are checked by
10
+ [travis-ci](http://travis-ci.org/nevans/resque-pool). It also explicitly
11
+ supports resque ~> 1.20. And (if you have `gem-man` installed), it now has man
12
+ pages for bin and yml config.
13
+
14
+ Many thanks to the contributers!
15
+
16
+ * [@agnellvj](https://github.com/agnellvj): ruby 1.9 compatibility
17
+ * [@geoffgarside](https://github.com/geoffgarside): man pages!
18
+ * [@imajes](https://github.com/imajes) - bugfix: Handle when a pid no longer
19
+ exists by the time you try and kill it.
20
+ * [@jeremy](https://github.com/jeremy) & [@jamis](https://github.com/jamis) -
21
+ tasks require `resque/pool` lazily
22
+ * [@jhsu](https://github.com/jhsu) - bugfix: undefined variable 'e' for errors
23
+ * [@gaffneyc](https://github.com/gaffneyc) - compatibility fix:
24
+ Resque::Pool::PooledWorker as a module rather than class
25
+ * [@kcrayon](https://github.com/kcrayon) - bugfix: fix worker shutdown
26
+ * [@alexkwolfe](https://github.com/alexkwolfe) - added `app_name` for logging
27
+ (and maybe more in the future?)
28
+
29
+ ## 0.2.0 (2011-03-15)
30
+
31
+ * new feature: sending `HUP` to pool manager will reload the logfiles and
32
+ gracefully restart all workers.
33
+ * enhancement: logging now includes timestamp, process "name" (worker or
34
+ manager), and PID.
35
+ * enhancement: can be used with no config file or empty config file (not all
36
+ *that* useful, but it's better than unceromoniously dieing!)
37
+ * bugfix: pidfile will be cleaned up on startup, e.g. if old process was
38
+ kill-9'd (Jason Haruska)
39
+ * bugfix: TERM/INT are no longer ignored when HUP is waiting on children
40
+ * bugfix: `resque-pool -c config.yml` command line option was broken
41
+ * development: simple cucumber features for core functionality.
42
+ * upstream: depends on resque ~> 1.13
43
+
44
+ ## 0.1.0 (2011-01-18)
45
+
46
+ * new feature: `resque-pool` command line interface
47
+ * this replaces need for a special startup script.
48
+ * manages PID file, logfiles, daemonizing, etc.
49
+ * `resque-pool --help` for more info and options
50
+ * updated example config, init.d script, including a chef recipe that should
51
+ work at EngineYard.
52
+
53
+ ## 0.0.10 (2010-08-31)
54
+
55
+ * remove rubygems 1.3.6 dependency
56
+
57
+ ## 0.0.9 (2010-08-26)
58
+
59
+ * new feature: `RESQUE_POOL_CONFIG` environment variable to set alt config file
60
+ * upgraded to resque 1.10, removing `Resque::Worker` monkeypatch
61
+
62
+ ## 0.0.8 (2010-08-20)
63
+
64
+ * bugfix: using (or not using) environments in config file
65
+
66
+ ## 0.0.7 (2010-08-16)
67
+
68
+ * new feature: split by environments in config file
69
+ * added example startup script, Rakefile, and monit config
70
+
71
+ ## 0.0.5 (2010-06-29)
72
+
73
+ * bugfix: worker processes not shutting down after orphaned
74
+
75
+ ## 0.0.4 (2010-06-29)
76
+
77
+ * first release used in production
@@ -0,0 +1,20 @@
1
+ Copyright (C) 2010 by Nicholas Evans <nick@ekenosen.net>, et al.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
@@ -0,0 +1,164 @@
1
+ Resque Pool
2
+ ===========
3
+
4
+ [![Build Status](https://secure.travis-ci.org/nevans/resque-pool.png)](http://travis-ci.org/nevans/resque-pool)
5
+ [![Dependency Status](https://gemnasium.com/nevans/resque-pool.png)](https://gemnasium.com/nevans/resque-pool)
6
+
7
+ Resque pool is a simple library for managing a pool of
8
+ [resque](http://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.
11
+
12
+ Benefits
13
+ ---------
14
+
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.
21
+ * 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.
24
+
25
+ Upgrading?
26
+ -----------
27
+
28
+ See
29
+ [Changelog.md](https://github.com/nevans/resque-pool/blob/master/Changelog.md)
30
+ in case there are important or helpful changes.
31
+
32
+ How to use
33
+ -----------
34
+
35
+ ### YAML file config
36
+
37
+ Create a `config/resque-pool.yml` (or `resque-pool.yml`) with your worker
38
+ counts. The YAML file supports both using root level defaults as well as
39
+ environment specific overrides (`RACK_ENV`, `RAILS_ENV`, and `RESQUE_ENV`
40
+ environment variables can be used to determine environment). For example in
41
+ `config/resque-pool.yml`:
42
+
43
+ foo: 1
44
+ bar: 2
45
+ "foo,bar,baz": 1
46
+
47
+ production:
48
+ "foo,bar,baz": 4
49
+
50
+ ### Rake task config
51
+
52
+ Require the rake tasks (`resque/pool/tasks`) in your `Rakefile`, load your
53
+ application environment, configure Resque as necessary, and configure
54
+ `resque:pool:setup` to disconnect all open files and sockets in the pool
55
+ manager and reconnect in the workers. For example, with rails you should put
56
+ the following into `lib/tasks/resque.rake`:
57
+
58
+ require 'resque/pool/tasks'
59
+ # this task will get called before resque:pool:setup
60
+ # and preload the rails environment in the pool manager
61
+ task "resque:setup" => :environment do
62
+ # generic worker setup, e.g. Hoptoad for failed jobs
63
+ end
64
+ task "resque:pool:setup" do
65
+ # close any sockets or files in pool manager
66
+ ActiveRecord::Base.connection.disconnect!
67
+ # and re-open them in the resque worker parent
68
+ Resque::Pool.after_prefork do |job|
69
+ ActiveRecord::Base.establish_connection
70
+ end
71
+ end
72
+
73
+ ### Start the pool manager
74
+
75
+ Then you can start the queues via:
76
+
77
+ resque-pool --daemon --environment production
78
+
79
+ This will start up seven worker processes, one exclusively for the foo queue,
80
+ two exclusively for the bar queue, and four workers looking at all queues in
81
+ priority. With the config above, this is similar to if you ran the following:
82
+
83
+ rake resque:work RAILS_ENV=production QUEUES=foo &
84
+ rake resque:work RAILS_ENV=production QUEUES=bar &
85
+ rake resque:work RAILS_ENV=production QUEUES=bar &
86
+ rake resque:work RAILS_ENV=production QUEUES=foo,bar,baz &
87
+ rake resque:work RAILS_ENV=production QUEUES=foo,bar,baz &
88
+ rake resque:work RAILS_ENV=production QUEUES=foo,bar,baz &
89
+ rake resque:work RAILS_ENV=production QUEUES=foo,bar,baz &
90
+
91
+ The pool manager will stay around monitoring the resque worker parents, giving
92
+ three levels: a single pool manager, many worker parents, and one worker child
93
+ per worker (when the actual job is being processed). For example, `ps -ef f |
94
+ grep [r]esque` (in Linux) might return something like the following:
95
+
96
+ resque 13858 1 0 13:44 ? S 0:02 resque-pool-manager: managing [13867, 13875, 13871, 13872, 13868, 13870, 13876]
97
+ resque 13867 13858 0 13:44 ? S 0:00 \_ resque-1.9.9: Waiting for foo
98
+ resque 13868 13858 0 13:44 ? S 0:00 \_ resque-1.9.9: Waiting for bar
99
+ resque 13870 13858 0 13:44 ? S 0:00 \_ resque-1.9.9: Waiting for bar
100
+ resque 13871 13858 0 13:44 ? S 0:00 \_ resque-1.9.9: Waiting for foo,bar,baz
101
+ resque 13872 13858 0 13:44 ? S 0:00 \_ resque-1.9.9: Forked 7481 at 1280343254
102
+ resque 7481 13872 0 14:54 ? S 0:00 \_ resque-1.9.9: Processing foo since 1280343254
103
+ resque 13875 13858 0 13:44 ? S 0:00 \_ resque-1.9.9: Waiting for foo,bar,baz
104
+ resque 13876 13858 0 13:44 ? S 0:00 \_ resque-1.9.9: Forked 7485 at 1280343255
105
+ resque 7485 13876 0 14:54 ? S 0:00 \_ resque-1.9.9: Processing bar since 1280343254
106
+
107
+ Running as a daemon will default to placing the pidfile and logfiles in the
108
+ conventional rails locations, although you can configure that. See
109
+ `resque-pool --help` for more options.
110
+
111
+ SIGNALS
112
+ -------
113
+
114
+ The pool manager responds to the following signals:
115
+
116
+ * `HUP` - reload the config file, reload logfiles, restart all workers.
117
+ * `QUIT` - gracefully shut down workers (via `QUIT`) and shutdown the manager
118
+ after all workers are done.
119
+ * `INT` - gracefully shut down workers (via `QUIT`) and immediately shutdown manager
120
+ * `TERM` - immediately shut down workers (via `INT`) and immediately shutdown manager
121
+ _(configurable via command line options)_
122
+ * `WINCH` - _(only when running as a daemon)_ send `QUIT` to each worker, but
123
+ keep manager running (send `HUP` to reload config and restart workers)
124
+ * `USR1`/`USR2`/`CONT` - pass the signal on to all worker parents (see Resque docs).
125
+
126
+ Use `HUP` to help logrotate run smoothly and to change the number of workers
127
+ per worker type. Signals can be sent via the `kill` command, e.g.
128
+ `kill -HUP $master_pid`
129
+
130
+ If the environment variable `TERM_CHILD` is set, `QUIT` and `TERM` will respond as
131
+ defined by Resque 1.22 and above. See http://hone.heroku.com/resque/2012/08/21/resque-signals.html
132
+ for details, overriding any command-line configuration for `TERM`. Setting `TERM_CHILD` tells
133
+ us you know what you're doing.
134
+
135
+ Other Features
136
+ --------------
137
+
138
+ An example chef cookbook is provided (and should Just Work at Engine Yard as
139
+ is; just provide a `/data/#{app_name}/shared/config/resque-pool.yml` on your
140
+ utility instances). Even if you don't use chef you can use the example init.d
141
+ and monitrc erb templates in `examples/chef_cookbook/templates/default`.
142
+
143
+ You can also start a pool manager via `rake resque:pool` or from a plain old
144
+ ruby script by calling `Resque::Pool.run`.
145
+
146
+ Workers will watch the pool manager, and gracefully shutdown (after completing
147
+ their current job) if the manager process disappears before them.
148
+
149
+ You can specify an alternate config file by setting the `RESQUE_POOL_CONFIG` or
150
+ with the `--config` command line option.
151
+
152
+ TODO
153
+ -----
154
+
155
+ See [the TODO list](https://github.com/nevans/resque-pool/issues) at github issues.
156
+
157
+ Contributors
158
+ -------------
159
+
160
+ * John Schult (config file can be split by environment)
161
+ * Stephen Celis (increased gemspec sanity)
162
+ * Vincent Agnello, Robert Kamunyori, Paul Kauders; for pairing with me at
163
+ B'more on Rails Open Source Hack Nights. :)
164
+
@@ -0,0 +1,30 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ # for loading the example config file in config/resque-pool.yml
5
+ require 'resque/pool/tasks'
6
+
7
+ require 'rspec/core/rake_task'
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.rspec_opts = ["-c", "-f progress"]
10
+ end
11
+
12
+ require 'cucumber/rake/task'
13
+ Cucumber::Rake::Task.new(:features) do |c|
14
+ c.profile = "rake"
15
+ end
16
+
17
+ task :default => [:spec, :features]
18
+
19
+ rule(/\.[1-9]$/ => [proc { |tn| "#{tn}.ronn" }]) do |t|
20
+ name = Resque::Pool.name.sub('::','-').upcase
21
+ version = "%s %s" % [name, Resque::Pool::VERSION.upcase]
22
+
23
+ manual = '--manual "%s"' % name
24
+ organization = '--organization "%s"' % version
25
+ sh "ronn #{manual} #{organization} <#{t.source} >#{t.name}"
26
+ end
27
+
28
+ file 'man/resque-pool.1'
29
+ file 'man/resque-pool.yml.5'
30
+ task :manpages => ['man/resque-pool.1','man/resque-pool.yml.5']
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
5
+
6
+ require 'resque/pool/cli'
7
+ Resque::Pool::CLI.run
@@ -0,0 +1,68 @@
1
+ Feature: Basic resque-pool daemon configuration and operation
2
+ To easily manage a pool of resque workers, resque-pool provides a daemon with
3
+ simple configuration. Static configuration is handled in the
4
+ config/config.yml file and dynamic configuration is handled in the Rakefile.
5
+
6
+ Background:
7
+ Given a file named "Rakefile" with:
8
+ """
9
+ require 'resque/pool/tasks'
10
+ """
11
+
12
+ Scenario: no config file
13
+ When I run the pool manager as "resque-pool"
14
+ Then the pool manager should report that it has started up
15
+ And the pool manager should report that the pool is empty
16
+ And the pool manager should have no child processes
17
+ When I send the pool manager the "QUIT" signal
18
+ Then the pool manager should finish
19
+ And the pool manager should report that it is finished
20
+
21
+ @slow_exit
22
+ Scenario: basic config file
23
+ Given a file named "config/resque-pool.yml" with:
24
+ """
25
+ foo: 1
26
+ bar: 2
27
+ "bar,baz": 3
28
+ """
29
+ When I run the pool manager as "resque-pool"
30
+ Then the pool manager should report that it has started up
31
+ And the pool manager should report that 6 workers are in the pool
32
+ And the pool manager should have 1 "foo" worker child processes
33
+ And the pool manager should have 2 "bar" worker child processes
34
+ And the pool manager should have 3 "bar,baz" worker child processes
35
+ When I send the pool manager the "QUIT" signal
36
+ Then the resque workers should all shutdown
37
+ And the pool manager should finish
38
+ And the pool manager should report that a "foo" worker has been reaped
39
+ And the pool manager should report that a "bar" worker has been reaped
40
+ And the pool manager should report that a "bar,baz" worker has been reaped
41
+ And the pool manager should report that it is finished
42
+
43
+ Scenario: daemonized
44
+ Given a directory named "log"
45
+ And a directory named "tmp/pids"
46
+ And a file named "config/resque-pool.yml" with:
47
+ """
48
+ foo: 2
49
+ bar: 4
50
+ "baz,quux": 4
51
+ """
52
+ When I run the pool manager as "resque-pool -d"
53
+ Then the pool manager should record its pid in "tmp/pids/resque-pool.pid"
54
+ And the pool manager should daemonize
55
+ And a file named "log/resque-pool.stdout.log" should exist
56
+ And a file named "log/resque-pool.stderr.log" should exist
57
+ And the pool manager should log that it has started up
58
+ And the pool manager should log that 10 workers are in the pool
59
+ And the pool manager should have 2 "foo" worker child processes
60
+ And the pool manager should have 4 "bar" worker child processes
61
+ And the pool manager should have 4 "baz,quux" worker child processes
62
+ When I send the pool manager the "QUIT" signal
63
+ Then the resque workers should all shutdown
64
+ And the pool manager daemon should finish
65
+ And the pool manager should log that a "foo" worker has been reaped
66
+ And the pool manager should log that a "bar" worker has been reaped
67
+ And the pool manager should log that a "baz,quux" worker has been reaped
68
+ And the pool manager should log that it is finished
@@ -0,0 +1,33 @@
1
+ # syntactic sugar, and separate ivar. daemons aren't interactive
2
+ When /^I run "([^"]*)" in the background$/ do |cmd|
3
+ run_background(unescape(cmd))
4
+ end
5
+
6
+ Then /^the (output|logfiles) should contain the following lines \(with interpolated \$PID\):$/ do |output_logfiles, partial_output|
7
+ interpolate_background_pid(partial_output).split("\n").each do |line|
8
+ output_or_log(output_logfiles).should include(line)
9
+ end
10
+ end
11
+
12
+ When /^I send "([^"]*)" the "([^"]*)" signal$/ do |cmd, signal|
13
+ send_signal(cmd, signal)
14
+ end
15
+
16
+ Then /^the "([^"]*)" process should finish$/ do |cmd|
17
+ # doesn't actually stop... just polls for exit
18
+ processes[cmd].stop
19
+ end
20
+
21
+ Before("@slow_exit") do
22
+ @aruba_timeout_seconds = 10
23
+ end
24
+
25
+ After do
26
+ kill_all_processes!
27
+ # now kill the daemon!
28
+ begin
29
+ Process.kill(9, @pid_from_pidfile) if @pid_from_pidfile
30
+ rescue Errno::ESRCH
31
+ end
32
+ #`pkill -9 resque-pool`
33
+ end
@@ -0,0 +1,159 @@
1
+ def process_should_exist(pid)
2
+ lambda { Process.kill(0, pid) }.should_not raise_error(Errno::ESRCH)
3
+ end
4
+
5
+ def process_should_not_exist(pid)
6
+ lambda { Process.kill(0, pid) }.should raise_error(Errno::ESRCH)
7
+ end
8
+
9
+ def grab_worker_pids(count, str)
10
+ puts "TODO: check output_or_log for #{count} worker started messages"
11
+ pid_regex = (1..count).map { '(\d+)' }.join ', '
12
+ full_regex = /resque-pool-manager\[aruba\]\[\d+\]: Pool contains worker PIDs: \[#{pid_regex}\]/m
13
+ str.should =~ full_regex
14
+ @worker_pids = full_regex.match(str).captures.map {|pid| pid.to_i }
15
+ end
16
+
17
+ def output_or_logfiles_string(report_log)
18
+ case report_log
19
+ when "report", "output"
20
+ "output"
21
+ when "log", "logfiles"
22
+ "logfiles"
23
+ else
24
+ raise ArgumentError
25
+ end
26
+ end
27
+
28
+ def output_or_log(report_log)
29
+ case report_log
30
+ when "report", "output"
31
+ interactive_output
32
+ when "log", "logfiles"
33
+ in_current_dir do
34
+ File.read("log/resque-pool.stdout.log") << File.read("log/resque-pool.stderr.log")
35
+ end
36
+ else
37
+ raise ArgumentError
38
+ end
39
+ end
40
+
41
+ class NotFinishedStarting < StandardError; end
42
+ def worker_processes_for(queues)
43
+ children_of(background_pid).select do |pid, cmd|
44
+ raise NotFinishedStarting if cmd =~ /Starting$/
45
+ cmd =~ /^resque-\d+.\d+.\d+: Waiting for #{queues}$/
46
+ end
47
+ rescue NotFinishedStarting
48
+ retry
49
+ end
50
+
51
+ def children_of(ppid)
52
+ if RUBY_PLATFORM =~ /darwin/i
53
+ ps = `ps -eo ppid,pid,comm | grep '^ *#{ppid} '`
54
+ else
55
+ ps = `ps -eo ppid,pid,cmd | grep '^ *#{ppid} '`
56
+ end
57
+ ps.split(/\s*\n/).map do |line|
58
+ _, pid, cmd = line.strip.split(/\s+/, 3)
59
+ [pid, cmd]
60
+ end
61
+ end
62
+
63
+ When /^I run the pool manager as "([^"]*)"$/ do |cmd|
64
+ @pool_manager_process = run_background(unescape(cmd))
65
+ end
66
+
67
+ When /^I send the pool manager the "([^"]*)" signal$/ do |signal|
68
+ Process.kill signal, background_pid
69
+ output_logfiles = @pid_from_pidfile ? "logfiles" : "output"
70
+ case signal
71
+ when "QUIT"
72
+ keep_trying do
73
+ step "the #{output_logfiles} should contain the following lines (with interpolated $PID):", <<-EOF
74
+ resque-pool-manager[aruba][$PID]: QUIT: graceful shutdown, waiting for children
75
+ EOF
76
+ end
77
+ else
78
+ raise ArgumentError
79
+ end
80
+ end
81
+
82
+ Then /^the pool manager should record its pid in "([^"]*)"$/ do |pidfile|
83
+ in_current_dir do
84
+ keep_trying do
85
+ File.should be_file(pidfile)
86
+ @pid_from_pidfile = File.read(pidfile).to_i
87
+ @pid_from_pidfile.should_not == 0
88
+ process_should_exist(@pid_from_pidfile)
89
+ end
90
+ end
91
+ end
92
+
93
+ Then /^the pool manager should daemonize$/ do
94
+ stop_processes!
95
+ end
96
+
97
+ Then /^the pool manager daemon should finish$/ do
98
+ keep_trying do
99
+ process_should_not_exist(@pid_from_pidfile)
100
+ end
101
+ end
102
+
103
+ # nomenclature: "report" => output to stdout/stderr
104
+ # "log" => output to default logfile
105
+
106
+ Then /^the pool manager should (report|log) that it has started up$/ do |report_log|
107
+ keep_trying do
108
+ step "the #{output_or_logfiles_string(report_log)} should contain the following lines (with interpolated $PID):", <<-EOF
109
+ resque-pool-manager[aruba][$PID]: Resque Pool running in test environment
110
+ resque-pool-manager[aruba][$PID]: started manager
111
+ EOF
112
+ end
113
+ end
114
+
115
+ Then /^the pool manager should (report|log) that the pool is empty$/ do |report_log|
116
+ step "the #{output_or_logfiles_string(report_log)} should contain the following lines (with interpolated $PID):", <<-EOF
117
+ resque-pool-manager[aruba][$PID]: Pool is empty
118
+ EOF
119
+ end
120
+
121
+ Then /^the pool manager should (report|log) that (\d+) workers are in the pool$/ do |report_log, count|
122
+ grab_worker_pids Integer(count), output_or_log(report_log)
123
+ end
124
+
125
+ Then /^the resque workers should all shutdown$/ do
126
+ @worker_pids.each do |pid|
127
+ keep_trying do
128
+ process_should_not_exist(pid)
129
+ end
130
+ end
131
+ end
132
+
133
+ Then "the pool manager should have no child processes" do
134
+ children_of(background_pid).should have(:no).keys
135
+ end
136
+
137
+ Then /^the pool manager should have (\d+) "([^"]*)" worker child processes$/ do |count, queues|
138
+ worker_processes_for(queues).should have(Integer(count)).members
139
+ end
140
+
141
+ Then "the pool manager should finish" do
142
+ # assuming there will not be multiple processes running
143
+ stop_processes!
144
+ end
145
+
146
+ Then /^the pool manager should (report|log) that it is finished$/ do |report_log|
147
+ step "the #{output_or_logfiles_string(report_log)} should contain the following lines (with interpolated $PID):", <<-EOF
148
+ resque-pool-manager[aruba][$PID]: manager finished
149
+ EOF
150
+ end
151
+
152
+ Then /^the pool manager should (report|log) that a "([^"]*)" worker has been reaped$/ do |report_log, worker_type|
153
+ step 'the '+ output_or_logfiles_string(report_log) +' should match /Reaped resque worker\[\d+\] \(status: 0\) queues: '+ worker_type + '/'
154
+ end
155
+
156
+ Then /^the logfiles should match \/([^\/]*)\/$/ do |partial_output|
157
+ output_or_log("log").should =~ /#{partial_output}/
158
+ end
159
+