capistrano-sidekiq 0.2.6 → 0.2.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59d3f35bd7ebbfc7e6df0bff99cc2868ac0c2e8c
4
- data.tar.gz: 44686daa3a94f6c3df36bc17d9703391bf9c79aa
3
+ metadata.gz: ebc1abbf8019a19cb12257e5ef1be58b60cf5b7f
4
+ data.tar.gz: fc80367f3d79b9681c209f48d29c64e72c1c9ee1
5
5
  SHA512:
6
- metadata.gz: 4fcb69a80c59367e6300ad2a867d89305f10613ade1800e4c922b370b6f61da50d8eda13131104215b36924943a9461dd54aa59dda6fee3d7d3cc029295bc29d
7
- data.tar.gz: 494ad520b542a15cf8ec19d620df3edd06e25a245705af6f9f25203ddbb27359bc29c93fbee616966ee2c5fffa414823431e25503993448012725505100f69b7
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
 
@@ -1,4 +1,4 @@
1
- if Gem::Specification::find_by_name('capistrano').version >= Gem::Version.new('3.0.0')
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__)
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Sidekiq
3
- VERSION = '0.2.6'
3
+ VERSION = '0.2.7'
4
4
  end
5
5
  end
@@ -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', 'sidekiq: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
- pid_file = if idx.zero? && fetch(:sidekiq_processes) <= 1
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(' ')} ", :pty => false
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, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
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, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
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, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
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, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
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, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
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{ sidekiq sidekiqctl })
13
- set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w{ sidekiq sidekiqctl })
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 fetch(:stop_sidekiq_in_background, fetch(:sidekiq_run_in_background))
56
- background :bundle, :exec, :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
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 quit_sidekiq(pid_file)
63
- begin
64
- execute :bundle, :exec, :sidekiqctl, 'quiet', "#{pid_file}"
65
- rescue SSHKit::Command::Failed
66
- # If gems are not installed eq(first deploy) and sidekiq_default_hooks as active
67
- warn 'sidekiqctl not found (ignore if this is the first deploy)'
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 ">/dev/null 2>&1 &"
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 "--daemon"
93
+ args.push '--daemon'
86
94
  end
87
95
 
88
- if fetch(:start_sidekiq_in_background, fetch(:sidekiq_run_in_background))
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} ]") #fixes #11
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
- quit_sidekiq(pid_file)
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
- #delete any pid file not in use
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
- File.join('lib','capistrano','templates',"#{from}-#{role.hostname}-#{fetch(:stage)}.rb"),
181
- File.join('lib','capistrano','templates',"#{from}-#{role.hostname}.rb"),
182
- File.join('lib','capistrano','templates',"#{from}-#{fetch(:stage)}.rb"),
183
- File.join('lib','capistrano','templates',"#{from}.rb.erb"),
184
- File.join('lib','capistrano','templates',"#{from}.rb"),
185
- File.join('lib','capistrano','templates',"#{from}.erb"),
186
- File.expand_path("../../templates/#{from}.rb.erb", __FILE__),
187
- File.expand_path("../../templates/#{from}.erb", __FILE__)
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.6
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-16 00:00:00.000000000 Z
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.0.3
82
+ rubygems_version: 2.2.2
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Sidekiq integration for Capistrano