capistrano-sidekiq 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/capistrano/sidekiq.rb +1 -1
- data/lib/capistrano/sidekiq/monit.rb +1 -1
- data/lib/capistrano/sidekiq/version.rb +1 -1
- data/lib/capistrano/tasks/capistrano2.rb +10 -10
- data/lib/capistrano/tasks/sidekiq.cap +34 -27
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebc1abbf8019a19cb12257e5ef1be58b60cf5b7f
|
4
|
+
data.tar.gz: fc80367f3d79b9681c209f48d29c64e72c1c9ee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbc73ca5ff458753c9b1ae3ca28e2120380ecda81bc146534930b9a9cf640fc028c21a19897da5251c55935cb0156cf22e644ed5a389047acfe1bd65b4b4e0de
|
7
|
+
data.tar.gz: d869d15a31d51ed10daba29a1d244684f09ad8c8b843ec2d306296b07263f00310d69ef86ae584a5d09f73d4e6823bbe89c214c6ef5f257c6a77bbb695dcedb9
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ Add this line to your application's Gemfile:
|
|
10
10
|
|
11
11
|
or:
|
12
12
|
|
13
|
-
gem 'capistrano-sidekiq'
|
13
|
+
gem 'capistrano-sidekiq' , group: :development
|
14
14
|
|
15
15
|
And then execute:
|
16
16
|
|
@@ -43,6 +43,7 @@ Configurable options, shown here with defaults:
|
|
43
43
|
:sidekiqctl_cmd => "#{fetch(:bundle_cmd, "bundle")} exec sidekiqctl" # Only for capistrano2.5
|
44
44
|
```
|
45
45
|
## Changelog
|
46
|
+
- 0.2.7: Signal usage @penso
|
46
47
|
- 0.2.6: sidekiq:start check if sidekiq is running
|
47
48
|
- 0.2.5: bug fixes
|
48
49
|
- 0.2.4: Fast deploy with :sidekiq_run_in_background
|
@@ -52,6 +53,7 @@ Configurable options, shown here with defaults:
|
|
52
53
|
## Contributors
|
53
54
|
|
54
55
|
- [Jérémy Lecour] (https://github.com/jlecour)
|
56
|
+
- [Fabien Penso] (https://github.com/penso)
|
55
57
|
|
56
58
|
## Contributing
|
57
59
|
|
data/lib/capistrano/sidekiq.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
if Gem::Specification
|
1
|
+
if Gem::Specification.find_by_name('capistrano').version >= Gem::Version.new('3.0.0')
|
2
2
|
load File.expand_path('../tasks/sidekiq.cap', __FILE__)
|
3
3
|
else
|
4
4
|
require_relative 'tasks/capistrano2'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
#load monit tasks
|
1
|
+
# load monit tasks
|
2
2
|
load File.expand_path('../../tasks/monit.cap', __FILE__)
|
@@ -17,7 +17,7 @@ Capistrano::Configuration.instance.load do
|
|
17
17
|
|
18
18
|
if fetch(:sidekiq_default_hooks)
|
19
19
|
before 'deploy:update_code', 'sidekiq:quiet'
|
20
|
-
after 'deploy:stop',
|
20
|
+
after 'deploy:stop', 'sidekiq:stop'
|
21
21
|
after 'deploy:start', 'sidekiq:start'
|
22
22
|
before 'deploy:restart', 'sidekiq:restart'
|
23
23
|
end
|
@@ -25,10 +25,10 @@ Capistrano::Configuration.instance.load do
|
|
25
25
|
namespace :sidekiq do
|
26
26
|
def for_each_process(&block)
|
27
27
|
fetch(:sidekiq_processes).times do |idx|
|
28
|
-
|
29
|
-
fetch(:sidekiq_pid)
|
28
|
+
if idx.zero? && fetch(:sidekiq_processes) <= 1
|
29
|
+
pid_file = fetch(:sidekiq_pid)
|
30
30
|
else
|
31
|
-
fetch(:sidekiq_pid).gsub(/\.pid$/, "-#{idx}.pid")
|
31
|
+
pid_file = fetch(:sidekiq_pid).gsub(/\.pid$/, "-#{idx}.pid")
|
32
32
|
end
|
33
33
|
yield(pid_file, idx)
|
34
34
|
end
|
@@ -57,32 +57,32 @@ Capistrano::Configuration.instance.load do
|
|
57
57
|
args.push '--daemon'
|
58
58
|
end
|
59
59
|
|
60
|
-
run "cd #{current_path} ; #{fetch(:sidekiq_cmd)} #{args.compact.join(' ')} ", :
|
60
|
+
run "cd #{current_path} ; #{fetch(:sidekiq_cmd)} #{args.compact.join(' ')} ", pty: false
|
61
61
|
end
|
62
62
|
|
63
63
|
desc 'Quiet sidekiq (stop accepting new work)'
|
64
|
-
task :quiet, :
|
64
|
+
task :quiet, roles: lambda { fetch(:sidekiq_role) }, on_no_matching_servers: :continue do
|
65
65
|
for_each_process do |pid_file, idx|
|
66
66
|
quiet_process(pid_file, idx)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
desc 'Stop sidekiq'
|
71
|
-
task :stop, :
|
71
|
+
task :stop, roles: lambda { fetch(:sidekiq_role) }, on_no_matching_servers: :continue do
|
72
72
|
for_each_process do |pid_file, idx|
|
73
73
|
stop_process(pid_file, idx)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
desc 'Start sidekiq'
|
78
|
-
task :start, :
|
78
|
+
task :start, roles: lambda { fetch(:sidekiq_role) }, on_no_matching_servers: :continue do
|
79
79
|
for_each_process do |pid_file, idx|
|
80
80
|
start_process(pid_file, idx)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
desc 'Rolling-restart sidekiq'
|
85
|
-
task :rolling_restart, :
|
85
|
+
task :rolling_restart, roles: lambda { fetch(:sidekiq_role) }, on_no_matching_servers: :continue do
|
86
86
|
for_each_process do |pid_file, idx|
|
87
87
|
stop_process(pid_file, idx)
|
88
88
|
start_process(pid_file, idx)
|
@@ -90,7 +90,7 @@ Capistrano::Configuration.instance.load do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
desc 'Restart sidekiq'
|
93
|
-
task :restart, :
|
93
|
+
task :restart, roles: lambda { fetch(:sidekiq_role) }, on_no_matching_servers: :continue do
|
94
94
|
stop
|
95
95
|
start
|
96
96
|
end
|
@@ -9,8 +9,8 @@ namespace :load do
|
|
9
9
|
set :sidekiq_role, -> { :app }
|
10
10
|
set :sidekiq_processes, -> { 1 }
|
11
11
|
# Rbenv and RVM integration
|
12
|
-
set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w
|
13
|
-
set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w
|
12
|
+
set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w(sidekiq sidekiqctl))
|
13
|
+
set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w(sidekiq sidekiqctl))
|
14
14
|
end
|
15
15
|
|
16
16
|
end
|
@@ -22,7 +22,7 @@ namespace :deploy do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
namespace :sidekiq do
|
25
|
-
def for_each_process(reverse=false, &block)
|
25
|
+
def for_each_process(reverse = false, &block)
|
26
26
|
pids = processes_pids
|
27
27
|
pids.reverse! if reverse
|
28
28
|
pids.each_with_index do |pid_file, idx|
|
@@ -52,19 +52,27 @@ namespace :sidekiq do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def stop_sidekiq(pid_file)
|
55
|
-
if
|
56
|
-
|
55
|
+
if fetch(:stop_sidekiq_in_background, fetch(:sidekiq_run_in_background))
|
56
|
+
if fetch(:sidekiq_use_signals)
|
57
|
+
background "kill -TERM `cat #{pid_file}`"
|
58
|
+
else
|
59
|
+
background :bundle, :exec, :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
|
60
|
+
end
|
57
61
|
else
|
58
62
|
execute :bundle, :exec, :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
|
59
63
|
end
|
60
64
|
end
|
61
65
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
def quiet_sidekiq(pid_file)
|
67
|
+
if fetch(:sidekiq_use_signals)
|
68
|
+
background "kill -USR1 `cat #{pid_file}`"
|
69
|
+
else
|
70
|
+
begin
|
71
|
+
execute :bundle, :exec, :sidekiqctl, 'quiet', "#{pid_file}"
|
72
|
+
rescue SSHKit::Command::Failed
|
73
|
+
# If gems are not installed eq(first deploy) and sidekiq_default_hooks as active
|
74
|
+
warn 'sidekiqctl not found (ignore if this is the first deploy)'
|
75
|
+
end
|
68
76
|
end
|
69
77
|
end
|
70
78
|
|
@@ -79,13 +87,13 @@ namespace :sidekiq do
|
|
79
87
|
args.push fetch(:sidekiq_options) if fetch(:sidekiq_options)
|
80
88
|
|
81
89
|
if defined?(JRUBY_VERSION)
|
82
|
-
args.push
|
90
|
+
args.push '>/dev/null 2>&1 &'
|
83
91
|
warn 'Since JRuby doesn\'t support Process.daemon, Sidekiq will not be running as a daemon.'
|
84
92
|
else
|
85
|
-
args.push
|
93
|
+
args.push '--daemon'
|
86
94
|
end
|
87
95
|
|
88
|
-
if
|
96
|
+
if fetch(:start_sidekiq_in_background, fetch(:sidekiq_run_in_background))
|
89
97
|
background :bundle, :exec, :sidekiq, args.compact.join(' ')
|
90
98
|
else
|
91
99
|
execute :bundle, :exec, :sidekiq, args.compact.join(' ')
|
@@ -102,10 +110,10 @@ namespace :sidekiq do
|
|
102
110
|
desc 'Quiet sidekiq (stop processing new tasks)'
|
103
111
|
task :quiet do
|
104
112
|
on roles fetch(:sidekiq_role) do
|
105
|
-
if test("[ -d #{current_path} ]")
|
113
|
+
if test("[ -d #{current_path} ]") # fixes #11
|
106
114
|
for_each_process(true) do |pid_file, idx|
|
107
115
|
if pid_process_exists?(pid_file)
|
108
|
-
|
116
|
+
quiet_sidekiq(pid_file)
|
109
117
|
end
|
110
118
|
end
|
111
119
|
end
|
@@ -150,7 +158,7 @@ namespace :sidekiq do
|
|
150
158
|
end
|
151
159
|
end
|
152
160
|
|
153
|
-
#
|
161
|
+
# Delete any pid file not in use
|
154
162
|
task :cleanup do
|
155
163
|
on roles fetch(:sidekiq_role) do
|
156
164
|
for_each_process do |pid_file, idx|
|
@@ -161,7 +169,7 @@ namespace :sidekiq do
|
|
161
169
|
end
|
162
170
|
end
|
163
171
|
|
164
|
-
#TODO : Don't start if all proccess are off, raise warning.
|
172
|
+
# TODO : Don't start if all proccess are off, raise warning.
|
165
173
|
desc 'Respawn missing sidekiq proccesses'
|
166
174
|
task :respawn do
|
167
175
|
invoke 'sidekiq:cleanup'
|
@@ -174,17 +182,16 @@ namespace :sidekiq do
|
|
174
182
|
end
|
175
183
|
end
|
176
184
|
|
177
|
-
|
178
185
|
def template_sidekiq(from, to, role)
|
179
186
|
[
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
187
|
+
File.join('lib', 'capistrano', 'templates', "#{from}-#{role.hostname}-#{fetch(:stage)}.rb"),
|
188
|
+
File.join('lib', 'capistrano', 'templates', "#{from}-#{role.hostname}.rb"),
|
189
|
+
File.join('lib', 'capistrano', 'templates', "#{from}-#{fetch(:stage)}.rb"),
|
190
|
+
File.join('lib', 'capistrano', 'templates', "#{from}.rb.erb"),
|
191
|
+
File.join('lib', 'capistrano', 'templates', "#{from}.rb"),
|
192
|
+
File.join('lib', 'capistrano', 'templates', "#{from}.erb"),
|
193
|
+
File.expand_path("../../templates/#{from}.rb.erb", __FILE__),
|
194
|
+
File.expand_path("../../templates/#{from}.erb", __FILE__)
|
188
195
|
].each do |path|
|
189
196
|
if File.file?(path)
|
190
197
|
erb = File.read(path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.2.2
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Sidekiq integration for Capistrano
|