capistrano-sidekiq 0.4.0 → 0.5.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: 7f252aeda1b342db98d4e78c48a596f62a08854b
4
- data.tar.gz: c8b03baafafcee0e6dc3ee5299a15684f8752c7e
3
+ metadata.gz: 48c5d99cac41dcbb290d8d230db6ca3ea78d4390
4
+ data.tar.gz: 3b715312a4ab804f6a512cc85dbb532b5275a64c
5
5
  SHA512:
6
- metadata.gz: ee796988057a1bb571c48366007131c778f70dbc20f0e2d64b7660e17144584d32a403f0a914aa4ead634d5b5d0f7fe3227d9aabb8decae26f229a723afc5f82
7
- data.tar.gz: 94d89cd024d5fc60cdccd529bf8bc2195c4bf8bbf654204d2117e1147ded1e63d1a4111df9a504aca771161419e11965cb5dac7279277b3e84d214a27d194124
6
+ metadata.gz: e74d344619f3f9adca9b6f81cdd58c9a8ceba9332f06c5b33d06d50cec57f83c7e45e357582b9ba5a9497987ad6b89aa16b044706dcff848568255fcae158407
7
+ data.tar.gz: 1cb59160d9c6b1fc20c6645f12ce1b3272f82c6ea4e364d0f5cf979c4eeae7253ab6cba40cf8be96e8e73808bfb391a3f2b74b04c4bfeb16034be1e3e82fbb95
data/README.md CHANGED
@@ -9,11 +9,11 @@ Sidekiq integration for Capistrano
9
9
 
10
10
  Add this line to your application's Gemfile:
11
11
 
12
- gem 'capistrano-sidekiq' , github: 'seuros/capistrano-sidekiq'
12
+ gem 'capistrano-sidekiq', github: 'seuros/capistrano-sidekiq'
13
13
 
14
14
  or:
15
15
 
16
- gem 'capistrano-sidekiq' , group: :development
16
+ gem 'capistrano-sidekiq', group: :development
17
17
 
18
18
  And then execute:
19
19
 
@@ -32,20 +32,22 @@ And then execute:
32
32
  Configurable options, shown here with defaults:
33
33
 
34
34
  ```ruby
35
- :sidekiq_default_hooks => true
36
- :sidekiq_pid => File.join(shared_path, 'tmp', 'pids', 'sidekiq.pid')
37
- :sidekiq_env => fetch(:rack_env, fetch(:rails_env, fetch(:stage)))
38
- :sidekiq_log => File.join(shared_path, 'log', 'sidekiq.log')
39
- :sidekiq_options => nil
35
+ :sidekiq_default_hooks => true
36
+ :sidekiq_pid => File.join(shared_path, 'tmp', 'pids', 'sidekiq.pid')
37
+ :sidekiq_env => fetch(:rack_env, fetch(:rails_env, fetch(:stage)))
38
+ :sidekiq_log => File.join(shared_path, 'log', 'sidekiq.log')
39
+ :sidekiq_options => nil
40
40
  :sidekiq_require => nil
41
41
  :sidekiq_tag => nil
42
42
  :sidekiq_config => nil
43
43
  :sidekiq_queue => nil
44
- :sidekiq_timeout => 10
45
- :sidekiq_role => :app
46
- :sidekiq_processes => 1
44
+ :sidekiq_timeout => 10
45
+ :sidekiq_role => :app
46
+ :sidekiq_processes => 1
47
+ :sidekiq_options_per_process => nil
47
48
  :sidekiq_concurrency => nil
48
- :sidekiq_cmd => "#{fetch(:bundle_cmd, "bundle")} exec sidekiq" # Only for capistrano2.5
49
+ :sidekiq_monit_templates_path => 'config/deploy/templates'
50
+ :sidekiq_cmd => "#{fetch(:bundle_cmd, "bundle")} exec sidekiq" # Only for capistrano2.5
49
51
  :sidekiqctl_cmd => "#{fetch(:bundle_cmd, "bundle")} exec sidekiqctl" # Only for capistrano2.5
50
52
  ```
51
53
 
@@ -53,7 +55,31 @@ There is a known bug that prevents sidekiq from starting when pty is true
53
55
  ```ruby
54
56
  set :pty, false
55
57
  ```
58
+
59
+ ## Multiple processes
60
+
61
+ You can configure sidekiq to start with multiple processes. Just set the proper amount in `sidekiq_processes`.
62
+
63
+ You can also customize the configuration for every process. If you want to do that, just set
64
+ `sidekiq_options_per_process` with an array of the configuration options that you want in string format.
65
+ This example should boot the first process with the queue `high` and the second one with the queues `default`
66
+ and `low`:
67
+
68
+ ```ruby
69
+ set :sidekiq_options_per_process, ["--queue high", "--queue default --queue low"]
70
+ ```
71
+
72
+ ## Customizing the monit sidekiq templates
73
+
74
+ If you need change some config in redactor, you can
75
+
76
+ ```
77
+ bundle exec rails generate capistrano:sidekiq:monit:template
78
+
79
+ ```
80
+
56
81
  ## Changelog
82
+ - 0.5.0: Multiple processes @mrsimo
57
83
  - 0.3.9: Restore daemon flag from Monit template
58
84
  - 0.3.8:
59
85
  * Update monit template: use su instead of sudo / permit all Sidekiq options @bensie
@@ -64,7 +90,7 @@ set :pty, false
64
90
  - 0.3.5: Added :sidekiq_tag for capistrano2 @OscarBarrett
65
91
  - 0.3.4: fix bug in sidekiq:start for capistrano 2 task
66
92
  - 0.3.3: sidekiq:restart after deploy:restart added to default hooks
67
- - 0.3.2: :sidekiq_queue accept an array
93
+ - 0.3.2: :sidekiq_queue accept an array
68
94
  - 0.3.1: Fix logs @rottman, add concurrency option support @ungsophy
69
95
  - 0.3.0: Fix monit task @andreygerasimchuk
70
96
  - 0.2.9: Check if current directory exist @alexdunae
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Sidekiq
3
- VERSION = '0.4.0'
3
+ VERSION = '0.5.0'
4
4
  end
5
5
  end
@@ -7,7 +7,9 @@ Capistrano::Configuration.instance.load do
7
7
  _cset(:sidekiq_tag) { nil }
8
8
  _cset(:sidekiq_log) { File.join(shared_path, 'log', 'sidekiq.log') }
9
9
 
10
+ _cset(:sidekiq_config) { "#{current_path}/config/sidekiq.yml" }
10
11
  _cset(:sidekiq_options) { nil }
12
+ _cset(:sidekiq_queue) { nil }
11
13
 
12
14
  _cset(:sidekiq_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec sidekiq" }
13
15
  _cset(:sidekiqctl_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec sidekiqctl" }
@@ -15,6 +17,7 @@ Capistrano::Configuration.instance.load do
15
17
  _cset(:sidekiq_timeout) { 10 }
16
18
  _cset(:sidekiq_role) { :app }
17
19
  _cset(:sidekiq_processes) { 1 }
20
+ _cset(:sidekiq_options_per_process) { nil }
18
21
 
19
22
  if fetch(:sidekiq_default_hooks)
20
23
  before 'deploy:update_code', 'sidekiq:quiet'
@@ -50,6 +53,15 @@ Capistrano::Configuration.instance.load do
50
53
  args.push "--environment #{fetch(:sidekiq_env)}"
51
54
  args.push "--tag #{fetch(:sidekiq_tag)}" if fetch(:sidekiq_tag)
52
55
  args.push "--logfile #{fetch(:sidekiq_log)}" if fetch(:sidekiq_log)
56
+ args.push "--config #{fetch(:sidekiq_config)}" if fetch(:sidekiq_config)
57
+ fetch(:sidekiq_queue).each do |queue|
58
+ args.push "--queue #{queue}"
59
+ end if fetch(:sidekiq_queue)
60
+
61
+ if process_options = fetch(:sidekiq_options_per_process)
62
+ args.push process_options[idx]
63
+ end
64
+
53
65
  args.push fetch(:sidekiq_options)
54
66
 
55
67
  if defined?(JRUBY_VERSION)
@@ -18,16 +18,26 @@ namespace :sidekiq do
18
18
  namespace :monit do
19
19
 
20
20
  task :add_default_hooks do
21
- after 'deploy:check', 'sidekiq:monit:unmonitor'
22
- after 'deploy:publishing', 'sidekiq:monit:monitor'
21
+ before 'deploy:updating', 'sidekiq:monit:unmonitor'
22
+ after 'deploy:published', 'sidekiq:monit:monitor'
23
23
  end
24
24
 
25
25
  desc 'Config Sidekiq monit-service'
26
26
  task :config do
27
27
  on roles(fetch(:sidekiq_role)) do |role|
28
28
  @role = role
29
- template_sidekiq 'sidekiq_monit.conf', "#{fetch(:tmp_dir)}/monit.conf", @role
30
- sudo "mv #{fetch(:tmp_dir)}/monit.conf #{fetch(:sidekiq_monit_conf_dir)}/#{sidekiq_service_name}.conf"
29
+ template_sidekiq 'sidekiq_monit', "#{fetch(:tmp_dir)}/monit.conf", @role
30
+
31
+ mv_command = "mv #{fetch(:tmp_dir)}/monit.conf #{fetch(:sidekiq_monit_conf_dir)}/#{sidekiq_service_name}.conf"
32
+
33
+ # Try execute in case the deploy user doesn't have sudo to mv
34
+ begin
35
+ execute mv_command
36
+ rescue
37
+ sudo mv_command
38
+ end
39
+
40
+ sudo "#{fetch(:monit_bin)} reload"
31
41
  end
32
42
  end
33
43
 
@@ -35,7 +45,12 @@ namespace :sidekiq do
35
45
  task :monitor do
36
46
  on roles(fetch(:sidekiq_role)) do
37
47
  fetch(:sidekiq_processes).times do |idx|
38
- sudo "#{fetch(:monit_bin)} monitor #{sidekiq_service_name(idx)}"
48
+ begin
49
+ sudo "#{fetch(:monit_bin)} monitor #{sidekiq_service_name(idx)}"
50
+ rescue
51
+ invoke 'sidekiq:monit:config'
52
+ sudo "#{fetch(:monit_bin)} monitor #{sidekiq_service_name(idx)}"
53
+ end
39
54
  end
40
55
  end
41
56
  end
@@ -44,7 +59,11 @@ namespace :sidekiq do
44
59
  task :unmonitor do
45
60
  on roles(fetch(:sidekiq_role)) do
46
61
  fetch(:sidekiq_processes).times do |idx|
47
- sudo "#{fetch(:monit_bin)} unmonitor #{sidekiq_service_name(idx)}"
62
+ begin
63
+ sudo "#{fetch(:monit_bin)} unmonitor #{sidekiq_service_name(idx)}"
64
+ rescue
65
+ # no worries here
66
+ end
48
67
  end
49
68
  end
50
69
  end
@@ -8,9 +8,12 @@ namespace :load do
8
8
  set :sidekiq_timeout, -> { 10 }
9
9
  set :sidekiq_role, -> { :app }
10
10
  set :sidekiq_processes, -> { 1 }
11
+ set :sidekiq_options_per_process, -> { nil }
11
12
  # Rbenv and RVM integration
12
13
  set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w(sidekiq sidekiqctl))
13
14
  set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w(sidekiq sidekiqctl))
15
+
16
+ set :sidekiq_monit_templates_path, -> { 'config/deploy/templates' }
14
17
  end
15
18
  end
16
19
 
@@ -92,6 +95,9 @@ namespace :sidekiq do
92
95
  end
93
96
  args.push "--config #{fetch(:sidekiq_config)}" if fetch(:sidekiq_config)
94
97
  args.push "--concurrency #{fetch(:sidekiq_concurrency)}" if fetch(:sidekiq_concurrency)
98
+ if process_options = fetch(:sidekiq_options_per_process)
99
+ args.push process_options[idx]
100
+ end
95
101
  # use sidekiq_options for special options
96
102
  args.push fetch(:sidekiq_options) if fetch(:sidekiq_options)
97
103
 
@@ -180,8 +186,8 @@ namespace :sidekiq do
180
186
  end
181
187
  end
182
188
 
183
- # TODO : Don't start if all proccess are off, raise warning.
184
- desc 'Respawn missing sidekiq proccesses'
189
+ # TODO : Don't start if all processes are off, raise warning.
190
+ desc 'Respawn missing sidekiq processes'
185
191
  task :respawn do
186
192
  invoke 'sidekiq:cleanup'
187
193
  on roles fetch(:sidekiq_role) do
@@ -195,14 +201,16 @@ namespace :sidekiq do
195
201
 
196
202
  def template_sidekiq(from, to, role)
197
203
  [
198
- File.join('lib', 'capistrano', 'templates', "#{from}-#{role.hostname}-#{fetch(:stage)}.rb"),
199
- File.join('lib', 'capistrano', 'templates', "#{from}-#{role.hostname}.rb"),
200
- File.join('lib', 'capistrano', 'templates', "#{from}-#{fetch(:stage)}.rb"),
201
- File.join('lib', 'capistrano', 'templates', "#{from}.rb.erb"),
202
- File.join('lib', 'capistrano', 'templates', "#{from}.rb"),
203
- File.join('lib', 'capistrano', 'templates', "#{from}.erb"),
204
- File.expand_path("../../templates/#{from}.rb.erb", __FILE__),
205
- File.expand_path("../../templates/#{from}.erb", __FILE__)
204
+ "#{fetch(:sidekiq_monit_templates_path)}/#{from}.erb",
205
+ File.join('lib', 'capistrano', 'templates', "#{from}-#{role.hostname}-#{fetch(:stage)}.conf.rb"),
206
+ File.join('lib', 'capistrano', 'templates', "#{from}-#{role.hostname}-#{fetch(:stage)}.conf.rb"),
207
+ File.join('lib', 'capistrano', 'templates', "#{from}-#{role.hostname}.conf.rb"),
208
+ File.join('lib', 'capistrano', 'templates', "#{from}-#{fetch(:stage)}.conf.rb"),
209
+ File.join('lib', 'capistrano', 'templates', "#{from}.conf.rb.erb"),
210
+ File.join('lib', 'capistrano', 'templates', "#{from}.conf.rb"),
211
+ File.join('lib', 'capistrano', 'templates', "#{from}.conf.erb"),
212
+ File.expand_path("../../../generators/capistrano/sidekiq/monit/templates/#{from}.conf.rb.erb", __FILE__),
213
+ File.expand_path("../../../generators/capistrano/sidekiq/monit/templates/#{from}.conf.erb", __FILE__)
206
214
  ].each do |path|
207
215
  if File.file?(path)
208
216
  erb = File.read(path)
@@ -0,0 +1,24 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Capistrano
4
+ module Sidekiq
5
+ module Monit
6
+ module Generators
7
+ class TemplateGenerator < Rails::Generators::Base
8
+
9
+ namespace "capistrano:sidekiq:monit:template"
10
+ desc "Create local monitrc.erb, and erb files for monitored processes for customization"
11
+ source_root File.expand_path('../templates', __FILE__)
12
+ argument :templates_path, type: :string,
13
+ default: "config/deploy/templates",
14
+ banner: "path to templates"
15
+
16
+ def copy_template
17
+ copy_file "sidekiq_monit.conf.erb", "#{templates_path}/sidekiq_monit.erb"
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
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.4.0
4
+ version: 0.5.0
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-11-12 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -58,7 +58,8 @@ files:
58
58
  - lib/capistrano/tasks/capistrano2.rb
59
59
  - lib/capistrano/tasks/monit.cap
60
60
  - lib/capistrano/tasks/sidekiq.cap
61
- - lib/capistrano/templates/sidekiq_monit.conf.erb
61
+ - lib/generators/capistrano/sidekiq/monit/template_generator.rb
62
+ - lib/generators/capistrano/sidekiq/monit/templates/sidekiq_monit.conf.erb
62
63
  homepage: https://github.com/seuros/capistrano-sidekiq
63
64
  licenses:
64
65
  - LGPL-3.0
@@ -79,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
80
  version: '0'
80
81
  requirements: []
81
82
  rubyforge_project:
82
- rubygems_version: 2.2.2
83
+ rubygems_version: 2.4.5
83
84
  signing_key:
84
85
  specification_version: 4
85
86
  summary: Sidekiq integration for Capistrano