capistrano-sidekiq 3.1.0 → 3.2.0

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
  SHA256:
3
- metadata.gz: 61bb07339f25aae4a39fa10cb0dad5b696b13d89bb29e2c626d4d930cab246dc
4
- data.tar.gz: fca70af00d2a413d6bd84d7ab9f40ff678000f32f6699b5bbb221704ab72eccc
3
+ metadata.gz: 40ec2af554f334c8b2ee7251460a2cb530490bdaa84467d4f7b799bbd91708bd
4
+ data.tar.gz: 47863fe4c06843041874692ab5f45a6e352bc6367bec5de23138f2311bad8e41
5
5
  SHA512:
6
- metadata.gz: 3e5ebaa925990b9e6896328a3d78e0a187c3f794870ef5ed47fb0828f7a709236817020918aee2cd0cb7601e7b3bc739b36060a686abebd0988ed81f611d7a1e
7
- data.tar.gz: 9325d11d20b43003c085dd645e66d9028b30d87ed8c8422bdd01996afdd7fb6b35cc9e34ecf794f410c10d6499e426620f44a1ec1bd3f34ec53e641fcffb082f
6
+ metadata.gz: 67b0f52888ea111e29d797f0565c11415a8eb8806bf3809c3d4229cd369175ee665fe43570bbc7d2317949fe876ff42e7d585345b2a3ee8c2f997cfb7b12763e
7
+ data.tar.gz: 8b3a5307a8221910c346f1967e05c7cfe1be65e0dfae9f996b53226ed28a8ee0fb3e3b7cf3c742c2769e0d67fc90942d181e0116078e656fa768dcc1672dc176
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased](https://github.com/seuros/capistrano-sidekiq/compare/v3.1.0...master)
3
+ ## [Unreleased](https://github.com/seuros/capistrano-sidekiq/compare/v3.2.0...master)
4
+
5
+ ## [3.2.0](https://github.com/seuros/capistrano-sidekiq/compare/v3.1.0...v3.2.0) - 2025-06-22
6
+
7
+ ### Changed
8
+ - Harmonized interface with capistrano-puma for better ecosystem consistency
9
+ - Aligned configuration variable naming patterns
10
+ - Unified systemd command execution methods
11
+ - Standardized template search order across both gems
12
+ - Added documentation reference to example application
4
13
 
5
14
  ## [3.1.0](https://github.com/seuros/capistrano-sidekiq/compare/v3.0.0...v3.1.0) - 2025-06-22
6
15
 
data/README.md CHANGED
@@ -5,6 +5,15 @@
5
5
 
6
6
  Sidekiq integration for Capistrano - providing systemd service management and deployment coordination for Sidekiq 7+.
7
7
 
8
+ ## Example Application
9
+
10
+ For a complete working example of this gem in action, see the [capistrano-example-app](https://github.com/seuros/capistrano-example-app) which demonstrates:
11
+ - Rails 8.0 deployment with Capistrano
12
+ - Sidekiq 7.0 with Redis 7+
13
+ - Systemd service management
14
+ - rbenv integration
15
+ - Complete deployment guide
16
+
8
17
  ## Installation
9
18
 
10
19
  Add to your Gemfile:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Capistrano
4
- SIDEKIQ_VERSION = '3.1.0'
4
+ SIDEKIQ_VERSION = '3.2.0'
5
5
  end
@@ -5,22 +5,31 @@ require 'capistrano/plugin'
5
5
 
6
6
  module Capistrano
7
7
  module SidekiqCommon
8
- def compiled_template(config_file = 'sidekiq.yml')
8
+ def compiled_template_sidekiq(from, role, config_file = 'sidekiq.yml')
9
+ @role = role
9
10
  @config_file = config_file
10
- local_template_directory = fetch(:sidekiq_service_templates_path)
11
- search_paths = [
12
- File.join(local_template_directory, 'sidekiq.service.capistrano.erb'),
13
- File.expand_path(
14
- File.join(*%w[.. templates sidekiq.service.capistrano.erb]),
15
- __FILE__
16
- )
17
- ]
18
- template_path = search_paths.detect { |path| File.file?(path) }
19
- template = File.read(template_path)
20
- ERB.new(template, trim_mode: '-').result(binding)
11
+ file = [
12
+ "lib/capistrano/templates/#{from}-#{role.hostname}-#{fetch(:stage)}.rb",
13
+ "lib/capistrano/templates/#{from}-#{role.hostname}.rb",
14
+ "lib/capistrano/templates/#{from}-#{fetch(:stage)}.rb",
15
+ "lib/capistrano/templates/#{from}.rb.erb",
16
+ "lib/capistrano/templates/#{from}.rb",
17
+ "lib/capistrano/templates/#{from}.erb",
18
+ "config/deploy/templates/#{from}.rb.erb",
19
+ "config/deploy/templates/#{from}.rb",
20
+ "config/deploy/templates/#{from}.erb",
21
+ File.expand_path("../templates/#{from}.erb", __FILE__),
22
+ File.expand_path("../templates/#{from}.rb.erb", __FILE__)
23
+ ].detect { |path| File.file?(path) }
24
+ erb = File.read(file)
25
+ StringIO.new(ERB.new(erb, trim_mode: '-').result(binding))
21
26
  end
22
27
 
23
- def expanded_bundle_path
28
+ def template_sidekiq(from, to, role, config_file = 'sidekiq.yml')
29
+ backend.upload! compiled_template_sidekiq(from, role, config_file), to
30
+ end
31
+
32
+ def expanded_bundle_command
24
33
  backend.capture(:echo, SSHKit.config.command_map[:bundle]).strip
25
34
  end
26
35
 
@@ -28,12 +37,12 @@ module Capistrano
28
37
  "--config config/#{@config_file}" if @config_file != 'sidekiq.yml'
29
38
  end
30
39
 
31
- def switch_user(role, &)
40
+ def sidekiq_switch_user(role, &block)
32
41
  su_user = sidekiq_user(role)
33
42
  if su_user == role.user
34
43
  yield
35
44
  else
36
- backend.as(su_user, &)
45
+ backend.as(su_user, &block)
37
46
  end
38
47
  end
39
48
 
@@ -42,9 +51,11 @@ module Capistrano
42
51
  fetch(:sidekiq_user)
43
52
  else
44
53
  properties = role.properties
45
- properties.fetch(:sidekiq_user, nil) || # local property for sidekiq only
54
+ return role.user unless properties
55
+
56
+ properties.fetch(:sidekiq_user) || # local property for sidekiq only
46
57
  fetch(:sidekiq_user, nil) ||
47
- properties.fetch(:run_as, nil) || # global property across multiple capistrano gems
58
+ properties.fetch(:run_as) || # global property across multiple capistrano gems
48
59
  role.user
49
60
  end
50
61
  end
@@ -63,7 +74,7 @@ module Capistrano
63
74
  set_if_empty :sidekiq_configs, %w[sidekiq] # sidekiq.yml
64
75
 
65
76
  set_if_empty :sidekiq_log, -> { File.join(shared_path, 'log', 'sidekiq.log') }
66
- set_if_empty :sidekiq_error_log, -> { File.join(shared_path, 'log', 'sidekiq.log') }
77
+ set_if_empty :sidekiq_error_log, -> { File.join(shared_path, 'log', 'sidekiq_error.log') }
67
78
 
68
79
  set_if_empty :sidekiq_config_files, ['sidekiq.yml']
69
80
 
@@ -13,7 +13,7 @@ namespace :sidekiq do
13
13
  desc description
14
14
  task command do
15
15
  on roles fetch(:sidekiq_roles) do |role|
16
- git_plugin.switch_user(role) do
16
+ git_plugin.sidekiq_switch_user(role) do
17
17
  git_plugin.config_files(role).each do |config_file|
18
18
  git_plugin.execute_systemd(command, git_plugin.sidekiq_service_file_name(config_file))
19
19
  end
@@ -25,7 +25,7 @@ namespace :sidekiq do
25
25
  desc 'Quiet Sidekiq (stop fetching new tasks from Redis)'
26
26
  task :quiet do
27
27
  on roles fetch(:sidekiq_roles) do |role|
28
- git_plugin.switch_user(role) do
28
+ git_plugin.sidekiq_switch_user(role) do
29
29
  git_plugin.quiet_sidekiq(role)
30
30
  end
31
31
  end
@@ -34,7 +34,7 @@ namespace :sidekiq do
34
34
  desc 'Install Sidekiq systemd service'
35
35
  task :install do
36
36
  on roles fetch(:sidekiq_roles) do |role|
37
- git_plugin.switch_user(role) do
37
+ git_plugin.sidekiq_switch_user(role) do
38
38
  git_plugin.create_systemd_template(role)
39
39
  end
40
40
  end
@@ -45,7 +45,7 @@ namespace :sidekiq do
45
45
  task :uninstall do
46
46
  invoke 'sidekiq:disable'
47
47
  on roles fetch(:sidekiq_roles) do |role|
48
- git_plugin.switch_user(role) do
48
+ git_plugin.sidekiq_switch_user(role) do
49
49
  git_plugin.rm_systemd_service(role)
50
50
  end
51
51
  end
@@ -87,10 +87,10 @@ namespace :sidekiq do
87
87
  backend.execute :mkdir, '-p', systemd_path if fetch(:sidekiq_systemctl_user) != :system
88
88
 
89
89
  config_files(role).each do |config_file|
90
- ctemplate = compiled_template(config_file)
90
+ ctemplate = compiled_template_sidekiq('sidekiq.service.capistrano', role, config_file)
91
91
  temp_file_name = File.join('/tmp', "sidekiq.#{config_file}.service")
92
92
  systemd_file_name = File.join(systemd_path, sidekiq_service_file_name(config_file))
93
- backend.upload!(StringIO.new(ctemplate), temp_file_name)
93
+ backend.upload!(ctemplate, temp_file_name)
94
94
  if fetch(:sidekiq_systemctl_user) == :system
95
95
  warn "Installing #{systemd_file_name} as root"
96
96
  backend.execute :sudo, :mv, temp_file_name, systemd_file_name
@@ -21,9 +21,9 @@ WatchdogSec=10
21
21
  <%="User=#{sidekiq_user}" if fetch(:sidekiq_systemctl_user) == :system %>
22
22
  WorkingDirectory=<%= current_path %>
23
23
  <% if fetch(:sidekiq_use_login_shell) %>
24
- ExecStart=/bin/bash -lc '<%= expanded_bundle_path %> exec <%= fetch(:sidekiq_command) %> <%= fetch(:sidekiq_command_args) %> <%= sidekiq_config %>'
24
+ ExecStart=/bin/bash -lc '<%= expanded_bundle_command %> exec <%= fetch(:sidekiq_command) %> <%= fetch(:sidekiq_command_args) %> <%= sidekiq_config %>'
25
25
  <% else %>
26
- ExecStart=<%= expanded_bundle_path %> exec <%= fetch(:sidekiq_command) %> <%= fetch(:sidekiq_command_args) %> <%= sidekiq_config %>
26
+ ExecStart=<%= expanded_bundle_command %> exec <%= fetch(:sidekiq_command) %> <%= fetch(:sidekiq_command_args) %> <%= sidekiq_config %>
27
27
  <% end %>
28
28
 
29
29
  # Use `systemctl kill -s TSTP <% sidekiq_service_unit_name(@config_file) %>` to quiet the Sidekiq process
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih