capistrano-sidekiq-systemd 0.1.0 → 0.2.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecdeef1273903466bfbf2b1c8adaf58c9185f4f120c9da54ce7bd5759c5e9c6f
|
4
|
+
data.tar.gz: 7f87a9b25213435c5e4fc12ebe94a7cd6d28cb08a858072dd3cd9ccc631e089f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d05a25aebe6bd814a0f1087e458b53ec89c2acdc864a7e31351c2ff9ec097f4663c847be0f0ec5b00b7690218f09c5c21fd03204dc2bb391056a14f3ca7d59e
|
7
|
+
data.tar.gz: 77a2ca2fd421f5c918f4f6d43347ca42fc4348efbcc8d5e18caedbdff4edcac375ef92c67b76bb03ce8d564ae3adbf82264461f640afade90d656c558693003d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,7 @@ set :sidekiq_options_per_process, nil
|
|
36
36
|
set :sidekiq_user, nil
|
37
37
|
set :sidekiq_max_mem, nil
|
38
38
|
set :service_unit_name, "sidekiq-#{fetch(:stage)}.service"
|
39
|
+
set :sidekiq_service_unit_user => :user # :system
|
39
40
|
# Rbenv, Chruby, and RVM integration
|
40
41
|
set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w[sidekiq])
|
41
42
|
set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w[sidekiq])
|
@@ -7,6 +7,9 @@ namespace :load do
|
|
7
7
|
set :sidekiq_user, nil
|
8
8
|
set :sidekiq_max_mem, nil
|
9
9
|
set :service_unit_name, "sidekiq-#{fetch(:stage)}.service"
|
10
|
+
set :sidekiq_service_unit_user, :user
|
11
|
+
set :sidekiq_log, nil
|
12
|
+
set :sidekiq_error_log, nil
|
10
13
|
# Rbenv, Chruby, and RVM integration
|
11
14
|
set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w[sidekiq])
|
12
15
|
set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w[sidekiq])
|
@@ -42,7 +45,7 @@ namespace :sidekiq do
|
|
42
45
|
on roles fetch(:sidekiq_roles) do |role|
|
43
46
|
switch_user(role) do
|
44
47
|
sidekiq_options_per_process.each_index do |index|
|
45
|
-
|
48
|
+
systemctl(command: 'reload', service_unit_name: service_unit_name(index), raise_on_non_zero_exit: false)
|
46
49
|
end
|
47
50
|
end
|
48
51
|
end
|
@@ -53,7 +56,7 @@ namespace :sidekiq do
|
|
53
56
|
on roles fetch(:sidekiq_roles) do |role|
|
54
57
|
switch_user(role) do
|
55
58
|
sidekiq_options_per_process.each_index do |index|
|
56
|
-
|
59
|
+
systemctl(command: 'stop', service_unit_name: service_unit_name(index))
|
57
60
|
end
|
58
61
|
end
|
59
62
|
end
|
@@ -64,7 +67,7 @@ namespace :sidekiq do
|
|
64
67
|
on roles fetch(:sidekiq_roles) do |role|
|
65
68
|
switch_user(role) do
|
66
69
|
sidekiq_options_per_process.each_index do |index|
|
67
|
-
|
70
|
+
systemctl(command: 'start', service_unit_name: service_unit_name(index))
|
68
71
|
end
|
69
72
|
end
|
70
73
|
end
|
@@ -82,7 +85,7 @@ namespace :sidekiq do
|
|
82
85
|
switch_user(role) do
|
83
86
|
create_systemd_template(role)
|
84
87
|
sidekiq_options_per_process.each_index do |index|
|
85
|
-
|
88
|
+
systemctl(command: 'enable', service_unit_name: service_unit_name(index))
|
86
89
|
end
|
87
90
|
end
|
88
91
|
end
|
@@ -93,8 +96,8 @@ namespace :sidekiq do
|
|
93
96
|
on roles fetch(:sidekiq_roles) do |role|
|
94
97
|
switch_user(role) do
|
95
98
|
sidekiq_options_per_process.each_index do |index|
|
96
|
-
|
97
|
-
execute :rm, File.join(fetch(:service_unit_path,
|
99
|
+
systemctl(command: 'disable', service_unit_name: service_unit_name(index))
|
100
|
+
execute :rm, File.join(fetch(:service_unit_path, fetch_systemd_unit_path(capture(:pwd))), service_unit_name(index))
|
98
101
|
end
|
99
102
|
end
|
100
103
|
end
|
@@ -103,13 +106,17 @@ namespace :sidekiq do
|
|
103
106
|
def create_systemd_template(role)
|
104
107
|
template = File.read(File.expand_path('../../../../generators/capistrano/sidekiq/systemd/templates/sidekiq.service.capistrano.erb', __FILE__))
|
105
108
|
home_dir = capture :pwd
|
106
|
-
systemd_path = fetch(:service_unit_path,
|
109
|
+
systemd_path = fetch(:service_unit_path, fetch_systemd_unit_path(home_dir))
|
107
110
|
sidekiq_cmd = SSHKit.config.command_map[:sidekiq].gsub('~', home_dir)
|
108
|
-
|
111
|
+
if fetch(:sidekiq_service_unit_user) == :user
|
112
|
+
execute :mkdir, "-p", systemd_path
|
113
|
+
end
|
109
114
|
sidekiq_options_per_process.each_index do |index|
|
110
|
-
|
115
|
+
upload_template(data: StringIO.new(ERB.new(template).result(binding)),
|
116
|
+
systemd_path: systemd_path, service_unit_name: service_unit_name(index)
|
117
|
+
)
|
111
118
|
end
|
112
|
-
|
119
|
+
systemctl(command: 'daemon-reload')
|
113
120
|
end
|
114
121
|
|
115
122
|
def process_options(index = 0)
|
@@ -183,6 +190,33 @@ namespace :sidekiq do
|
|
183
190
|
end
|
184
191
|
end
|
185
192
|
|
193
|
+
def systemctl(command:, service_unit_name: nil, raise_on_non_zero_exit: true)
|
194
|
+
if fetch(:sidekiq_service_unit_user) == :user
|
195
|
+
execute :systemctl, "--user", command, service_unit_name, raise_on_non_zero_exit: raise_on_non_zero_exit
|
196
|
+
elsif fetch(:sidekiq_service_unit_user) == :system
|
197
|
+
execute :sudo, :systemctl, command, service_unit_name, raise_on_non_zero_exit: raise_on_non_zero_exit
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def fetch_systemd_unit_path(home_dir)
|
202
|
+
if fetch(:sidekiq_service_unit_user) == :user
|
203
|
+
File.join(home_dir, ".config", "systemd", "user")
|
204
|
+
elsif fetch(:sidekiq_service_unit_user) == :system
|
205
|
+
File.join("/", "etc", "systemd", "system")
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def upload_template(data:, systemd_path:, service_unit_name:)
|
210
|
+
temp_file_path = File.join('/', 'tmp', "#{service_unit_name}")
|
211
|
+
upload!(data, temp_file_path)
|
212
|
+
if fetch(:sidekiq_service_unit_user) == :system
|
213
|
+
execute :sudo, :mv, temp_file_path, File.join(systemd_path, service_unit_name)
|
214
|
+
else
|
215
|
+
execute :mv, temp_file_path, File.join(systemd_path, service_unit_name)
|
216
|
+
end
|
217
|
+
systemctl(command: 'daemon-reload')
|
218
|
+
end
|
219
|
+
|
186
220
|
def multiple_processes?
|
187
221
|
fetch(:sidekiq_options_per_process) && fetch(:sidekiq_options_per_process).size > 1
|
188
222
|
end
|
@@ -9,6 +9,9 @@ WorkingDirectory=<%= fetch(:deploy_to) %>/current
|
|
9
9
|
ExecStart=<%= sidekiq_cmd %> <%= process_options(index) %>
|
10
10
|
ExecReload=/bin/kill -TSTP $MAINPID
|
11
11
|
ExecStop=/bin/kill -TERM $MAINPID
|
12
|
+
<%="StandardOutput=append:#{fetch(:sidekiq_log)}" if fetch(:sidekiq_log) %>
|
13
|
+
<%="StandardError=append:#{fetch(:sidekiq_error_log)}" if fetch(:sidekiq_error_log) %>
|
14
|
+
<%="User=#{sidekiq_user(role)}" if sidekiq_user(role) %>
|
12
15
|
<%= "MemoryAccounting=#{ !!max_mem(index) }" if max_mem(index) %>
|
13
16
|
<%= "MemoryLimit=#{ max_mem(index) }" if max_mem(index) %>
|
14
17
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-sidekiq-systemd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- spilin
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -57,7 +57,7 @@ metadata:
|
|
57
57
|
homepage_uri: https://github.com/spilin/capistrano-sidekiq-systemd
|
58
58
|
source_code_uri: https://github.com/spilin/capistrano-sidekiq-systemd
|
59
59
|
changelog_uri: https://github.com/spilin/capistrano-sidekiq-systemd/CHANGELOG.md
|
60
|
-
post_install_message:
|
60
|
+
post_install_message:
|
61
61
|
rdoc_options: []
|
62
62
|
require_paths:
|
63
63
|
- lib
|
@@ -72,8 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
|
-
rubygems_version: 3.
|
76
|
-
signing_key:
|
75
|
+
rubygems_version: 3.2.15
|
76
|
+
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: Capistrano sidekiq systemd support
|
79
79
|
test_files: []
|