capistrano-sidekiq 2.0.0.beta5 → 2.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 +4 -4
- data/.tool-versions +1 -1
- data/CHANGELOG.md +221 -66
- data/Gemfile +4 -0
- data/README.md +25 -5
- data/Rakefile +8 -0
- data/capistrano-sidekiq.gemspec +0 -1
- data/lib/capistrano/sidekiq/helpers.rb +60 -0
- data/lib/capistrano/sidekiq/monit.rb +2 -0
- data/lib/capistrano/sidekiq/systemd.rb +4 -1
- data/lib/capistrano/sidekiq/upstart.rb +6 -2
- data/lib/capistrano/sidekiq/version.rb +1 -1
- data/lib/capistrano/sidekiq.rb +1 -0
- data/lib/capistrano/tasks/monit.rake +63 -104
- data/lib/capistrano/tasks/sidekiq.rake +1 -7
- data/lib/capistrano/tasks/systemd.rake +209 -51
- data/lib/capistrano/tasks/upstart.rake +14 -54
- data/lib/generators/capistrano/sidekiq/monit/templates/sidekiq_monit.conf.erb +4 -8
- data/lib/generators/capistrano/sidekiq/systemd/templates/sidekiq.service.capistrano.erb +51 -7
- metadata +9 -8
@@ -1,11 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
git_plugin = self
|
2
4
|
|
5
|
+
SUPPRESS_FAILURE = %w[|| echo NO_RUNNING_INSTANCE].freeze
|
6
|
+
|
3
7
|
namespace :sidekiq do
|
4
8
|
desc 'Quiet sidekiq (stop fetching new tasks from Redis)'
|
5
9
|
task :quiet do
|
6
10
|
on roles fetch(:sidekiq_roles) do |role|
|
7
11
|
git_plugin.switch_user(role) do
|
8
|
-
sudo :service, fetch(:sidekiq_service_unit_name), :reload
|
12
|
+
sudo :service, fetch(:sidekiq_service_unit_name), :reload, *SUPPRESS_FAILURE
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -14,7 +18,7 @@ namespace :sidekiq do
|
|
14
18
|
task :stop do
|
15
19
|
on roles fetch(:sidekiq_roles) do |role|
|
16
20
|
git_plugin.switch_user(role) do
|
17
|
-
sudo :service, fetch(:sidekiq_service_unit_name), :stop
|
21
|
+
sudo :service, fetch(:sidekiq_service_unit_name), :stop, *SUPPRESS_FAILURE
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
@@ -41,7 +45,8 @@ namespace :sidekiq do
|
|
41
45
|
task :uninstall do
|
42
46
|
on roles fetch(:sidekiq_roles) do |role|
|
43
47
|
git_plugin.switch_user(role) do
|
44
|
-
execute :rm, '-f',
|
48
|
+
execute :rm, '-f',
|
49
|
+
File.join(fetch(:service_unit_path, fetch_upstart_unit_path), fetch(:sidekiq_service_unit_name))
|
45
50
|
end
|
46
51
|
end
|
47
52
|
end
|
@@ -56,7 +61,7 @@ namespace :sidekiq do
|
|
56
61
|
def fetch_upstart_unit_path
|
57
62
|
if fetch(:sidekiq_service_unit_user) == :system
|
58
63
|
# if the path is not standard `set :service_unit_path`
|
59
|
-
|
64
|
+
'/etc/init'
|
60
65
|
else
|
61
66
|
home_dir = backend.capture :pwd
|
62
67
|
File.join(home_dir, '.config', 'upstart')
|
@@ -68,7 +73,7 @@ namespace :sidekiq do
|
|
68
73
|
File.expand_path(
|
69
74
|
File.join(*%w[.. .. .. generators capistrano sidekiq upstart templates sidekiq.conf.erb]),
|
70
75
|
__FILE__
|
71
|
-
)
|
76
|
+
)
|
72
77
|
]
|
73
78
|
template_path = search_paths.detect { |path| File.file?(path) }
|
74
79
|
template = File.read(template_path)
|
@@ -79,66 +84,21 @@ namespace :sidekiq do
|
|
79
84
|
ctemplate = compiled_template
|
80
85
|
upstart_path = fetch(:service_unit_path, fetch_upstart_unit_path)
|
81
86
|
|
82
|
-
if fetch(:sidekiq_service_unit_user) != :system
|
83
|
-
backend.execute :mkdir, "-p", upstart_path
|
84
|
-
end
|
87
|
+
backend.execute :mkdir, '-p', upstart_path if fetch(:sidekiq_service_unit_user) != :system
|
85
88
|
conf_filename = "#{fetch :sidekiq_service_unit_name}.conf"
|
86
89
|
backend.upload!(
|
87
90
|
StringIO.new(ctemplate),
|
88
91
|
"/tmp/#{conf_filename}"
|
89
92
|
)
|
93
|
+
backend.execute :sudo, :mv, "/tmp/#{conf_filename}", "#{upstart_path}/#{conf_filename}"
|
90
94
|
if fetch(:sidekiq_service_unit_user) == :system
|
91
|
-
backend.execute :sudo, :
|
92
|
-
backend.execute :sudo, :initctl, 'reload-configuration'
|
95
|
+
backend.execute :sudo, :initctl, 'reload-configuration'
|
93
96
|
else
|
94
|
-
backend.execute :sudo, :
|
95
|
-
#backend.execute :sudo, :initctl, 'reload-configuration' #TODO
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def switch_user(role)
|
100
|
-
su_user = sidekiq_user(role)
|
101
|
-
if su_user == role.user
|
102
|
-
yield
|
103
|
-
else
|
104
|
-
as su_user do
|
105
|
-
yield
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def sidekiq_user(role = nil)
|
111
|
-
if role.nil?
|
112
|
-
fetch(:sidekiq_user)
|
113
|
-
else
|
114
|
-
properties = role.properties
|
115
|
-
properties.fetch(:sidekiq_user) || # local property for sidekiq only
|
116
|
-
fetch(:sidekiq_user) ||
|
117
|
-
properties.fetch(:run_as) || # global property across multiple capistrano gems
|
118
|
-
role.user
|
97
|
+
# backend.execute :sudo, :initctl, 'reload-configuration' #TODO
|
119
98
|
end
|
120
99
|
end
|
121
100
|
|
122
101
|
def num_workers
|
123
102
|
fetch(:sidekiq_upstart_num_workers, nil)
|
124
103
|
end
|
125
|
-
|
126
|
-
def sidekiq_config
|
127
|
-
if fetch(:sidekiq_config)
|
128
|
-
"--config #{fetch(:sidekiq_config)}"
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def sidekiq_concurrency
|
133
|
-
if fetch(:sidekiq_concurrency)
|
134
|
-
"--concurrency #{fetch(:sidekiq_concurrency)}"
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
def sidekiq_queues
|
139
|
-
Array(fetch(:sidekiq_queue)).map do |queue|
|
140
|
-
"--queue #{queue}"
|
141
|
-
end.join(' ')
|
142
|
-
end
|
143
|
-
|
144
104
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
# Monit configuration for Sidekiq : <%= fetch(:application) %>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
stop program = "/bin/su - <%= sidekiq_user(@role) %> -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:sidekiqctl] %> stop <%= pid_file %>'" with timeout <%= fetch(:sidekiq_timeout).to_i + 10 %> seconds
|
2
|
+
check process <%= sidekiq_service_name %>
|
3
|
+
matching 'sidekiq .* <%= fetch(:full_app_name) %>'
|
4
|
+
start program = "/bin/su - <%= sidekiq_user(role) %> -c 'cd <%= current_path %> && <%= SSHKit.config.command_map[:bundle] %> exec sidekiq -e <%= fetch(:sidekiq_env) %> <%= sidekiq_config %> <%= sidekiq_concurrency %> <%= sidekiq_require %> <%= sidekiq_queues %> <%= sidekiq_logfile ? ">> #{sidekiq_logfile} 2>&1" : nil %> &'" with timeout 30 seconds
|
5
|
+
stop program = "/bin/su - <%= sidekiq_user(role) %> -c 'ps -ax | grep "<%= "sidekiq .* #{fetch(:full_app_name)}" %>" | grep -v grep | awk "{print \$1}" | xargs --no-run-if-empty kill'" with timeout <%= fetch(:sidekiq_timeout).to_i + 10 %> seconds
|
8
6
|
group <%= fetch(:sidekiq_monit_group) || fetch(:application) %>-sidekiq
|
9
|
-
|
10
|
-
<% end %>
|
@@ -1,25 +1,69 @@
|
|
1
|
+
# Source: https://github.com/mperham/sidekiq/blob/master/examples/systemd/sidekiq.service
|
2
|
+
#
|
3
|
+
# This file tells systemd how to run Sidekiq as a 24/7 long-running daemon.
|
4
|
+
#
|
5
|
+
# Customize this file based on your bundler location, app directory, etc.
|
6
|
+
# Customize and copy this into /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
|
7
|
+
# Then run:
|
8
|
+
# - systemctl enable sidekiq
|
9
|
+
# - systemctl {start,stop,restart} sidekiq
|
10
|
+
#
|
11
|
+
# This file corresponds to a single Sidekiq process. Add multiple copies
|
12
|
+
# to run multiple processes (sidekiq-1, sidekiq-2, etc).
|
13
|
+
#
|
14
|
+
# Use `journalctl -u sidekiq -rn 100` to view the last 100 lines of log output.
|
15
|
+
#
|
1
16
|
[Unit]
|
2
17
|
Description=sidekiq for <%= "#{fetch(:application)} (#{fetch(:stage)})" %>
|
18
|
+
# start us only once the network and logging subsystems are available,
|
19
|
+
# consider adding redis-server.service if Redis is local and systemd-managed.
|
3
20
|
After=syslog.target network.target
|
4
21
|
|
22
|
+
# See these pages for lots of options:
|
23
|
+
#
|
24
|
+
# https://www.freedesktop.org/software/systemd/man/systemd.service.html
|
25
|
+
# https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
26
|
+
#
|
27
|
+
# THOSE PAGES ARE CRITICAL FOR ANY LINUX DEVOPS WORK; read them multiple
|
28
|
+
# times! systemd is a critical tool for all developers to know and understand.
|
29
|
+
#
|
5
30
|
[Service]
|
6
|
-
|
31
|
+
#
|
32
|
+
# !!!! !!!! !!!!
|
33
|
+
#
|
34
|
+
# As of v6.0.6, Sidekiq automatically supports systemd's `Type=notify` and watchdog service
|
35
|
+
# monitoring. If you are using an earlier version of Sidekiq, change this to `Type=simple`
|
36
|
+
# and remove the `WatchdogSec` line.
|
37
|
+
#
|
38
|
+
# !!!! !!!! !!!!
|
39
|
+
#
|
40
|
+
Type=notify
|
41
|
+
# If your Sidekiq process locks up, systemd's watchdog will restart it within seconds.
|
42
|
+
WatchdogSec=10
|
43
|
+
|
7
44
|
WorkingDirectory=<%= File.join(fetch(:deploy_to), 'current') %>
|
8
|
-
ExecStart=<%=
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
<%="StandardError=append:#{fetch(:sidekiq_error_log)}" if fetch(:sidekiq_error_log) %>
|
45
|
+
ExecStart=<%= expanded_bundle_path %> exec sidekiq -e <%= fetch(:sidekiq_env) %> <%= sidekiq_config %> <%= sidekiq_concurrency %> <%= sidekiq_queues %>
|
46
|
+
|
47
|
+
# Use `systemctl kill -s TSTP sidekiq` to quiet the Sidekiq process
|
48
|
+
|
13
49
|
<%="User=#{sidekiq_user}" if sidekiq_user %>
|
14
|
-
|
50
|
+
UMask=0002
|
51
|
+
|
52
|
+
<%="EnvironmentFile=#{File.join(fetch(:deploy_to), 'current')}/#{fetch(:sidekiq_service_unit_env_file)}" if fetch(:sidekiq_service_unit_env_file) %>
|
15
53
|
|
16
54
|
<% fetch(:sidekiq_service_unit_env_vars, []).each do |environment_variable| %>
|
17
55
|
<%="Environment=#{environment_variable}" %>
|
18
56
|
<% end %>
|
19
57
|
|
58
|
+
# if we crash, restart
|
20
59
|
RestartSec=1
|
21
60
|
Restart=on-failure
|
22
61
|
|
62
|
+
# output goes to /var/log/syslog (Ubuntu) or /var/log/messages (CentOS)
|
63
|
+
<%="StandardOutput=append:#{fetch(:sidekiq_log)}" if fetch(:sidekiq_log) %>
|
64
|
+
<%="StandardError=append:#{fetch(:sidekiq_error_log)}" if fetch(:sidekiq_error_log) %>
|
65
|
+
|
66
|
+
# This will default to "bundler" if we don't specify it
|
23
67
|
SyslogIdentifier=sidekiq
|
24
68
|
|
25
69
|
[Install]
|
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: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- capistrano-sidekiq.gemspec
|
71
71
|
- lib/capistrano-sidekiq.rb
|
72
72
|
- lib/capistrano/sidekiq.rb
|
73
|
+
- lib/capistrano/sidekiq/helpers.rb
|
73
74
|
- lib/capistrano/sidekiq/monit.rb
|
74
75
|
- lib/capistrano/sidekiq/systemd.rb
|
75
76
|
- lib/capistrano/sidekiq/upstart.rb
|
@@ -87,7 +88,7 @@ homepage: https://github.com/seuros/capistrano-sidekiq
|
|
87
88
|
licenses:
|
88
89
|
- LGPL-3.0
|
89
90
|
metadata: {}
|
90
|
-
post_install_message:
|
91
|
+
post_install_message:
|
91
92
|
rdoc_options: []
|
92
93
|
require_paths:
|
93
94
|
- lib
|
@@ -98,12 +99,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
99
|
version: 2.0.0
|
99
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
101
|
requirements:
|
101
|
-
- - "
|
102
|
+
- - ">="
|
102
103
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
104
|
+
version: '0'
|
104
105
|
requirements: []
|
105
|
-
rubygems_version: 3.
|
106
|
-
signing_key:
|
106
|
+
rubygems_version: 3.2.22
|
107
|
+
signing_key:
|
107
108
|
specification_version: 4
|
108
109
|
summary: Sidekiq integration for Capistrano
|
109
110
|
test_files: []
|