capistrano-sidekiq 2.0.0 → 2.3.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 +235 -66
- data/Gemfile +4 -0
- data/README.md +24 -13
- data/Rakefile +8 -0
- data/capistrano-sidekiq.gemspec +0 -1
- data/lib/capistrano/sidekiq/helpers.rb +53 -0
- data/lib/capistrano/sidekiq/monit.rb +5 -1
- data/lib/capistrano/sidekiq/systemd.rb +7 -2
- data/lib/capistrano/sidekiq/version.rb +3 -1
- data/lib/capistrano/sidekiq.rb +5 -4
- data/lib/capistrano/tasks/monit.rake +63 -104
- data/lib/capistrano/tasks/sidekiq.rake +1 -7
- data/lib/capistrano/tasks/systemd.rake +212 -51
- data/lib/generators/capistrano/sidekiq/monit/templates/sidekiq_monit.conf.erb +7 -9
- data/lib/generators/capistrano/sidekiq/systemd/templates/sidekiq.service.capistrano.erb +50 -8
- metadata +4 -8
- data/CONTRIBUTORS.md +0 -11
- data/lib/capistrano/sidekiq/upstart.rb +0 -11
- data/lib/capistrano/tasks/upstart.rake +0 -146
- data/lib/generators/capistrano/sidekiq/upstart/templates/sidekiq.conf.erb +0 -78
- data/lib/generators/capistrano/sidekiq/upstart/templates/workers.conf.erb +0 -37
@@ -1,26 +1,68 @@
|
|
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_service_unit_name %>
|
9
|
+
# - systemctl {start,stop,restart} <%= sidekiq_service_unit_name %>
|
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_service_unit_name %> -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
|
-
<%="StandardOutput=append:#{fetch(:sidekiq_log)}" if fetch(:sidekiq_log) %>
|
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_service_unit_name %>` to quiet the Sidekiq process
|
13
48
|
<%="User=#{sidekiq_user}" if sidekiq_user %>
|
14
|
-
|
49
|
+
UMask=0002
|
50
|
+
|
51
|
+
<%="EnvironmentFile=#{File.join(fetch(:deploy_to), 'current')}/#{fetch(:sidekiq_service_unit_env_file)}" if fetch(:sidekiq_service_unit_env_file) %>
|
15
52
|
|
16
53
|
<% fetch(:sidekiq_service_unit_env_vars, []).each do |environment_variable| %>
|
17
54
|
<%="Environment=#{environment_variable}" %>
|
18
55
|
<% end %>
|
19
56
|
|
57
|
+
# if we crash, restart
|
20
58
|
RestartSec=1
|
21
59
|
Restart=on-failure
|
22
60
|
|
23
|
-
|
61
|
+
# output goes to /var/log/syslog (Ubuntu) or /var/log/messages (CentOS)
|
62
|
+
<%="StandardOutput=append:#{fetch(:sidekiq_log)}" if fetch(:sidekiq_log) %>
|
63
|
+
<%="StandardError=append:#{fetch(:sidekiq_error_log)}" if fetch(:sidekiq_error_log) %>
|
64
|
+
|
65
|
+
SyslogIdentifier=<%= sidekiq_service_unit_name %>
|
24
66
|
|
25
67
|
[Install]
|
26
68
|
WantedBy=default.target
|
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.3.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:
|
11
|
+
date: 2022-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- ".gitignore"
|
63
63
|
- ".tool-versions"
|
64
64
|
- CHANGELOG.md
|
65
|
-
- CONTRIBUTORS.md
|
66
65
|
- Gemfile
|
67
66
|
- LICENSE.txt
|
68
67
|
- README.md
|
@@ -70,19 +69,16 @@ files:
|
|
70
69
|
- capistrano-sidekiq.gemspec
|
71
70
|
- lib/capistrano-sidekiq.rb
|
72
71
|
- lib/capistrano/sidekiq.rb
|
72
|
+
- lib/capistrano/sidekiq/helpers.rb
|
73
73
|
- lib/capistrano/sidekiq/monit.rb
|
74
74
|
- lib/capistrano/sidekiq/systemd.rb
|
75
|
-
- lib/capistrano/sidekiq/upstart.rb
|
76
75
|
- lib/capistrano/sidekiq/version.rb
|
77
76
|
- lib/capistrano/tasks/monit.rake
|
78
77
|
- lib/capistrano/tasks/sidekiq.rake
|
79
78
|
- lib/capistrano/tasks/systemd.rake
|
80
|
-
- lib/capistrano/tasks/upstart.rake
|
81
79
|
- lib/generators/capistrano/sidekiq/monit/template_generator.rb
|
82
80
|
- lib/generators/capistrano/sidekiq/monit/templates/sidekiq_monit.conf.erb
|
83
81
|
- lib/generators/capistrano/sidekiq/systemd/templates/sidekiq.service.capistrano.erb
|
84
|
-
- lib/generators/capistrano/sidekiq/upstart/templates/sidekiq.conf.erb
|
85
|
-
- lib/generators/capistrano/sidekiq/upstart/templates/workers.conf.erb
|
86
82
|
homepage: https://github.com/seuros/capistrano-sidekiq
|
87
83
|
licenses:
|
88
84
|
- LGPL-3.0
|
@@ -102,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
98
|
- !ruby/object:Gem::Version
|
103
99
|
version: '0'
|
104
100
|
requirements: []
|
105
|
-
rubygems_version: 3.
|
101
|
+
rubygems_version: 3.2.22
|
106
102
|
signing_key:
|
107
103
|
specification_version: 4
|
108
104
|
summary: Sidekiq integration for Capistrano
|
data/CONTRIBUTORS.md
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
## Contributors
|
2
|
-
|
3
|
-
- [Jérémy Lecour] (https://github.com/jlecour)
|
4
|
-
- [Fabien Penso] (https://github.com/penso)
|
5
|
-
- [Alex Dunae] (https://github.com/alexdunae)
|
6
|
-
- [andreygerasimchuk] (https://github.com/andreygerasimchuk)
|
7
|
-
- [Saicheg] (https://github.com/Saicheg)
|
8
|
-
- [Alex Yakubenko] (https://github.com/alexyakubenko)
|
9
|
-
- [Robert Strobl] (https://github.com/rstrobl)
|
10
|
-
- [Eurico Doirado] (https://github.com/okoriko)
|
11
|
-
- [Huang Bin](https://github.com/hbin)
|
@@ -1,146 +0,0 @@
|
|
1
|
-
git_plugin = self
|
2
|
-
|
3
|
-
SUPPRESS_FAILURE = %w[|| echo NO_RUNNING_INSTANCE].freeze
|
4
|
-
|
5
|
-
namespace :sidekiq do
|
6
|
-
desc 'Quiet sidekiq (stop fetching new tasks from Redis)'
|
7
|
-
task :quiet do
|
8
|
-
on roles fetch(:sidekiq_roles) do |role|
|
9
|
-
git_plugin.switch_user(role) do
|
10
|
-
sudo :service, fetch(:sidekiq_service_unit_name), :reload, *SUPPRESS_FAILURE
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
desc 'Stop sidekiq (graceful shutdown within timeout, put unfinished tasks back to Redis)'
|
16
|
-
task :stop do
|
17
|
-
on roles fetch(:sidekiq_roles) do |role|
|
18
|
-
git_plugin.switch_user(role) do
|
19
|
-
sudo :service, fetch(:sidekiq_service_unit_name), :stop, *SUPPRESS_FAILURE
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'Start sidekiq'
|
25
|
-
task :start do
|
26
|
-
on roles fetch(:sidekiq_roles) do |role|
|
27
|
-
git_plugin.switch_user(role) do
|
28
|
-
sudo :service, fetch(:sidekiq_service_unit_name), :start
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
desc 'Install upstart sidekiq service'
|
34
|
-
task :install do
|
35
|
-
on roles fetch(:sidekiq_roles) do |role|
|
36
|
-
git_plugin.switch_user(role) do
|
37
|
-
git_plugin.create_upstart_template
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
desc 'UnInstall upstart sidekiq service'
|
43
|
-
task :uninstall do
|
44
|
-
on roles fetch(:sidekiq_roles) do |role|
|
45
|
-
git_plugin.switch_user(role) do
|
46
|
-
execute :rm, '-f', File.join(fetch(:service_unit_path, fetch_upstart_unit_path), fetch(:sidekiq_service_unit_name))
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
desc 'Generate service_locally'
|
52
|
-
task :generate_service_locally do
|
53
|
-
run_locally do
|
54
|
-
File.write('sidekiq.conf', git_plugin.compiled_template)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def fetch_upstart_unit_path
|
59
|
-
if fetch(:sidekiq_service_unit_user) == :system
|
60
|
-
# if the path is not standard `set :service_unit_path`
|
61
|
-
"/etc/init"
|
62
|
-
else
|
63
|
-
home_dir = backend.capture :pwd
|
64
|
-
File.join(home_dir, '.config', 'upstart')
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def compiled_template
|
69
|
-
search_paths = [
|
70
|
-
File.expand_path(
|
71
|
-
File.join(*%w[.. .. .. generators capistrano sidekiq upstart templates sidekiq.conf.erb]),
|
72
|
-
__FILE__
|
73
|
-
),
|
74
|
-
]
|
75
|
-
template_path = search_paths.detect { |path| File.file?(path) }
|
76
|
-
template = File.read(template_path)
|
77
|
-
ERB.new(template).result(binding)
|
78
|
-
end
|
79
|
-
|
80
|
-
def create_upstart_template
|
81
|
-
ctemplate = compiled_template
|
82
|
-
upstart_path = fetch(:service_unit_path, fetch_upstart_unit_path)
|
83
|
-
|
84
|
-
if fetch(:sidekiq_service_unit_user) != :system
|
85
|
-
backend.execute :mkdir, "-p", upstart_path
|
86
|
-
end
|
87
|
-
conf_filename = "#{fetch :sidekiq_service_unit_name}.conf"
|
88
|
-
backend.upload!(
|
89
|
-
StringIO.new(ctemplate),
|
90
|
-
"/tmp/#{conf_filename}"
|
91
|
-
)
|
92
|
-
if fetch(:sidekiq_service_unit_user) == :system
|
93
|
-
backend.execute :sudo, :mv, "/tmp/#{conf_filename}", "#{upstart_path}/#{conf_filename}"
|
94
|
-
backend.execute :sudo, :initctl, 'reload-configuration'
|
95
|
-
else
|
96
|
-
backend.execute :sudo, :mv, "/tmp/#{conf_filename}", "#{upstart_path}/#{conf_filename}"
|
97
|
-
#backend.execute :sudo, :initctl, 'reload-configuration' #TODO
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def switch_user(role)
|
102
|
-
su_user = sidekiq_user(role)
|
103
|
-
if su_user == role.user
|
104
|
-
yield
|
105
|
-
else
|
106
|
-
as su_user do
|
107
|
-
yield
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def sidekiq_user(role = nil)
|
113
|
-
if role.nil?
|
114
|
-
fetch(:sidekiq_user)
|
115
|
-
else
|
116
|
-
properties = role.properties
|
117
|
-
properties.fetch(:sidekiq_user) || # local property for sidekiq only
|
118
|
-
fetch(:sidekiq_user) ||
|
119
|
-
properties.fetch(:run_as) || # global property across multiple capistrano gems
|
120
|
-
role.user
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def num_workers
|
125
|
-
fetch(:sidekiq_upstart_num_workers, nil)
|
126
|
-
end
|
127
|
-
|
128
|
-
def sidekiq_config
|
129
|
-
if fetch(:sidekiq_config)
|
130
|
-
"--config #{fetch(:sidekiq_config)}"
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
def sidekiq_concurrency
|
135
|
-
if fetch(:sidekiq_concurrency)
|
136
|
-
"--concurrency #{fetch(:sidekiq_concurrency)}"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def sidekiq_queues
|
141
|
-
Array(fetch(:sidekiq_queue)).map do |queue|
|
142
|
-
"--queue #{queue}"
|
143
|
-
end.join(' ')
|
144
|
-
end
|
145
|
-
|
146
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# /etc/init/sidekiq.conf - Sidekiq config | https://github.com/mperham/sidekiq/blob/master/examples/upstart/sidekiq.conf
|
2
|
-
|
3
|
-
# This example config should work with Ubuntu 12.04+. It
|
4
|
-
# allows you to manage multiple Sidekiq instances with
|
5
|
-
# Upstart, Ubuntu's native service management tool.
|
6
|
-
#
|
7
|
-
# See workers.conf for how to manage all Sidekiq instances at once.
|
8
|
-
#
|
9
|
-
# Save this config as /etc/init/sidekiq.conf then manage sidekiq with:
|
10
|
-
# sudo start <%= fetch(:sidekiq_service_unit_name) %> index=0
|
11
|
-
# sudo stop <%= fetch(:sidekiq_service_unit_name) %> index=0
|
12
|
-
# sudo status <%= fetch(:sidekiq_service_unit_name) %> index=0
|
13
|
-
#
|
14
|
-
# Hack Upstart's reload command to 'quiet' Sidekiq:
|
15
|
-
#
|
16
|
-
# sudo reload <%= fetch(:sidekiq_service_unit_name) %> index=0
|
17
|
-
#
|
18
|
-
# or use the service command:
|
19
|
-
# sudo service <%= fetch(:sidekiq_service_unit_name) %> {start,stop,restart,status}
|
20
|
-
#
|
21
|
-
|
22
|
-
description "Sidekiq for <%= "#{fetch(:application)} (#{fetch(:stage)})" %>"
|
23
|
-
|
24
|
-
# This script is not meant to start on bootup, workers.conf
|
25
|
-
# will start all sidekiq instances explicitly when it starts.
|
26
|
-
#start on runlevel [2345]
|
27
|
-
#stop on runlevel [06]
|
28
|
-
<% if sidekiq_user %>
|
29
|
-
|
30
|
-
# change to match your deployment user
|
31
|
-
setuid <%= sidekiq_user %>
|
32
|
-
setgid <%= sidekiq_user %>
|
33
|
-
env HOME=/home/<%= sidekiq_user %>
|
34
|
-
<% end %>
|
35
|
-
|
36
|
-
# Greatly reduce Ruby memory fragmentation and heap usage
|
37
|
-
# https://www.mikeperham.com/2018/04/25/taming-rails-memory-bloat/
|
38
|
-
env MALLOC_ARENA_MAX=2
|
39
|
-
|
40
|
-
respawn
|
41
|
-
respawn limit 3 30
|
42
|
-
|
43
|
-
# TERM is used when stopping sidekiq. Without declaring these as
|
44
|
-
# normal exit codes, it just respawns.
|
45
|
-
normal exit 0 TERM
|
46
|
-
|
47
|
-
# Older versions of Upstart might not support the reload command and need
|
48
|
-
# this commented out.
|
49
|
-
reload signal TSTP
|
50
|
-
|
51
|
-
# Upstart waits 5 seconds by default to kill a process. Increase timeout to
|
52
|
-
# give sidekiq process enough time to exit.
|
53
|
-
kill timeout 30
|
54
|
-
<% if num_workers %>
|
55
|
-
|
56
|
-
instance $index
|
57
|
-
<% end %>
|
58
|
-
script
|
59
|
-
# this script runs in /bin/sh by default
|
60
|
-
# respawn as bash so we can source in rbenv
|
61
|
-
exec /bin/bash <<'EOT'
|
62
|
-
# Pick your poison :) Or none if you're using a system wide installed Ruby.
|
63
|
-
# rbenv
|
64
|
-
# source /home/apps/.bash_profile
|
65
|
-
# OR
|
66
|
-
# source /home/apps/.profile
|
67
|
-
# OR system:
|
68
|
-
# source /etc/profile.d/rbenv.sh
|
69
|
-
#
|
70
|
-
# rvm
|
71
|
-
# source /home/apps/.rvm/scripts/rvm
|
72
|
-
|
73
|
-
# Logs out to /var/log/upstart/<%= fetch(:sidekiq_service_unit_name) %>.log by default
|
74
|
-
|
75
|
-
cd <%= File.join(fetch(:deploy_to), 'current') %>
|
76
|
-
exec <%= SSHKit.config.command_map[:bundle] %> exec sidekiq -e <%= fetch(:sidekiq_env) %> <%= sidekiq_config %> <%= sidekiq_concurrency %> <%= sidekiq_queues %>
|
77
|
-
EOT
|
78
|
-
end script
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# /etc/init/workers.conf - manage a set of Sidekiqs | https://github.com/mperham/sidekiq/blob/master/examples/upstart/workers.conf
|
2
|
-
|
3
|
-
# This example config should work with Ubuntu 14.10 and below It
|
4
|
-
# allows you to manage multiple Sidekiq instances with
|
5
|
-
# Upstart, Ubuntu's native service management tool.
|
6
|
-
#
|
7
|
-
# See sidekiq.conf for how to manage a single Sidekiq instance.
|
8
|
-
#
|
9
|
-
# Use "stop workers" to stop all Sidekiq instances.
|
10
|
-
# Use "start workers" to start all instances.
|
11
|
-
# Use "restart workers" to restart all instances.
|
12
|
-
# Crazy, right?
|
13
|
-
#
|
14
|
-
|
15
|
-
description "manages the set of sidekiq processes"
|
16
|
-
|
17
|
-
# This starts upon bootup and stops on shutdown
|
18
|
-
start on runlevel [2345]
|
19
|
-
stop on runlevel [06]
|
20
|
-
|
21
|
-
# Set this to the number of Sidekiq processes you want
|
22
|
-
# to run on this machine
|
23
|
-
env NUM_WORKERS=2
|
24
|
-
|
25
|
-
pre-start script
|
26
|
-
for i in `seq 1 ${NUM_WORKERS}`
|
27
|
-
do
|
28
|
-
start sidekiq index=$i
|
29
|
-
done
|
30
|
-
end script
|
31
|
-
|
32
|
-
post-stop script
|
33
|
-
for i in `seq 1 ${NUM_WORKERS}`
|
34
|
-
do
|
35
|
-
stop sidekiq index=$i
|
36
|
-
done
|
37
|
-
end script
|