capistrano-resque-pool 0.0.2 → 0.1.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: f73cc8a2da3270261c3e005501b9ba6ab136cbd3
4
- data.tar.gz: 68100579457c1da70704d14f79b23ffb2908fbee
3
+ metadata.gz: 706da99c97ea705d8c6454c551c18f78212eabed
4
+ data.tar.gz: 88b38e72e580dbe67f7fb9247c64251f926e17c9
5
5
  SHA512:
6
- metadata.gz: 9f203a3671a2f1101baf05c370cedbd9a546e5539b4c93abb2a978a3a05b6f04cdf7319f16e879c48580fa7be3c9cb6b896eab5f7265c2aa2eaf240badb6cec9
7
- data.tar.gz: 78bebe514803ca6cc092444b71bb2923418d94805ead33b01fd2e7a11a9ea77d33008bc7453204220b408334c48390ff3616df4611e992f792e36210a2c2695f
6
+ metadata.gz: a1b4780bfd1e5afd6a5e030b4d373ee8566d64ee1737516cab9a5952bc9bcf29d74033dda2b21b26ed9acde19ff849b163f20bf6b513c3b6908b95fd38a3ded8
7
+ data.tar.gz: 2255a187f57b24ae1047f424fc3372a702095371245dbda09ed87123868b56150f8943251191203c3acc454bd78ad53060d0076225589f9ae1b7599e4be785e0
data/README.md CHANGED
@@ -34,6 +34,10 @@ Reload the config file, reload logfiles, restart all workers.
34
34
 
35
35
  bundle exec cap production resque:pool:restart
36
36
 
37
+ Gracefully shut down workers, Gracefully shut down manager, start a new manager and it's workers
38
+
39
+ bundle exec cap production resque:pool:full_restart
40
+
37
41
 
38
42
  ## Contributing
39
43
 
@@ -1,7 +1,7 @@
1
1
  module Capistrano
2
2
  module Resque
3
3
  module Pool
4
- VERSION = '0.0.2'
4
+ VERSION = '0.1.0'
5
5
  end
6
6
  end
7
7
  end
@@ -6,6 +6,7 @@ namespace :resque do
6
6
  fetch(:stage) # so we need to fall back to the stage.
7
7
  end
8
8
 
9
+
9
10
  desc 'Start all the workers and queus'
10
11
  task :start do
11
12
  on roles(workers) do
@@ -18,7 +19,15 @@ namespace :resque do
18
19
  desc 'Gracefully shut down workers and shutdown the manager after all workers are done'
19
20
  task :stop do
20
21
  on roles(workers) do
21
- execute :kill, "-s QUIT `cat #{pid_path}`"
22
+ if pid_file_exists?
23
+ pid = capture(:cat, pid_path)
24
+ if test "kill -0 #{pid} > /dev/null 2>&1"
25
+ execute :kill, "-s QUIT #{pid}"
26
+ else
27
+ info "Process #{pid} from #{pid_path} is not running, cleaning up stale PID file"
28
+ execute :rm, pid_path
29
+ end
30
+ end
22
31
  end
23
32
  end
24
33
 
@@ -29,10 +38,30 @@ namespace :resque do
29
38
  end
30
39
  end
31
40
 
41
+ desc 'Stop the workers and the manager, re-start them (with a different pid)'
42
+ task :full_restart do
43
+ invoke 'resque:pool:stop'
44
+
45
+ # Wait for the manager to stop
46
+ on roles(workers) do
47
+ info "Waiting for pool manager to stop.. "
48
+ if pid_file_exists?
49
+ pid = capture(:cat, pid_path)
50
+ tries = 10
51
+ while tries >= 0 and test("kill -0 #{pid} > /dev/null 2>&1")
52
+ tries =- 1
53
+ sleep 5
54
+ end
55
+ end
56
+ end
57
+
58
+ invoke 'resque:pool:start'
59
+ end
60
+
32
61
  desc 'Reload the config file, reload logfiles, restart all workers'
33
62
  task :restart do
34
63
  on roles(workers) do
35
- if test("[ -f #{pid_path} ]")
64
+ if pid_file_exists?
36
65
  execute :kill, "-s HUP `cat #{pid_path}`"
37
66
  else
38
67
  invoke 'resque:pool:start'
@@ -48,6 +77,10 @@ namespace :resque do
48
77
  File.join(app_path, '/tmp/pids/resque-pool.pid')
49
78
  end
50
79
 
80
+ def pid_file_exists?
81
+ return test("[ -f #{pid_path} ]")
82
+ end
83
+
51
84
  def workers
52
85
  fetch(:resque_server_roles) || :app
53
86
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-resque-pool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Abramchuk
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-09 00:00:00.000000000 Z
12
+ date: 2016-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler