sidekiq-redeploy 0.1.7 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +11 -0
- data/README.md +1 -0
- data/bin/sidekiq-loader +7 -1
- data/lib/sidekiq/redeploy/loader.rb +44 -32
- data/lib/sidekiq/redeploy/version.rb +1 -1
- data/sidekiq-redeploy.gemspec +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b4a9ea82326d3303e7b62977a3a124415b5b763ad3ab12e952fff7464794910
|
4
|
+
data.tar.gz: 9b876740e30131c3c6c4c3da743d04cb5922e616af690b1ad6561bb716e2e973
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28ac5b4d9853c1538e1db4a98144280d2814d3a3799a3e3e0297db54b470e2cc13b9c721e7d0cf0c8a37cc23b764581fa6206e524eb973b5b3633934b7aff4c1
|
7
|
+
data.tar.gz: a7699606e5abba66b5d2ef82b11317de3ece6042234ab45d1491b61ab8e2ceec1fcfa7c9d71a79c6242405fe773b21e0b16b73e46c221a465b65ace4c296589d
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -40,6 +40,7 @@ Usage: sidekiq-loader [options]
|
|
40
40
|
-y, --watch-delay INTEGER [Optional] Specify the number of seconds between checking watch file. Defaults to 30.
|
41
41
|
-d, --[no-]deploy [FLAG] [Optional] Deploy archive on app startup. Defaults to true.
|
42
42
|
-s, --sidekiq-app [PATH|DIR] [Optional] Location of application to pass to sidekiq.
|
43
|
+
-n, --num-procs INTEGER [Optional] Specify the number of sidekiq processes to create. Defaults to 1.
|
43
44
|
```
|
44
45
|
|
45
46
|
For example this will start the launcher using a S3 watch file.
|
data/bin/sidekiq-loader
CHANGED
@@ -13,7 +13,8 @@ def run_sidekiq(ops, logger)
|
|
13
13
|
deployer.deploy(source: deployer.archive_file) if ops[:deploy]
|
14
14
|
config = { watch_delay: ops[:watch_delay] }
|
15
15
|
|
16
|
-
Sidekiq::Redeploy::Loader.new(deployer:, logger:, sidekiq_app: ops[:sidekiq_app], config
|
16
|
+
Sidekiq::Redeploy::Loader.new(deployer:, logger:, sidekiq_app: ops[:sidekiq_app], config:,
|
17
|
+
num_processes: ops[:num_processes]).run
|
17
18
|
end
|
18
19
|
|
19
20
|
def option_parser(opts)
|
@@ -39,6 +40,11 @@ def option_parser(opts)
|
|
39
40
|
o.on '-s', '--sidekiq-app [PATH|DIR]', '[Optional] Location of application to pass to sidekiq.' do |arg|
|
40
41
|
opts[:sidekiq_app] = arg
|
41
42
|
end
|
43
|
+
|
44
|
+
o.on '-n', '--num-procs INTEGER', Integer,
|
45
|
+
'[Optional] Specify the number of sidekiq processes to create. Defaults to 1.' do |arg|
|
46
|
+
opts[:num_processes] = arg
|
47
|
+
end
|
42
48
|
end
|
43
49
|
end
|
44
50
|
|
@@ -15,9 +15,8 @@ module Sidekiq
|
|
15
15
|
|
16
16
|
SIGNALS = [INT, TERM, USR2, TTIN].freeze
|
17
17
|
|
18
|
-
def initialize(deployer:, sidekiq_app: nil, logger: Logger.new($stdout), config: {})
|
18
|
+
def initialize(deployer:, sidekiq_app: nil, logger: Logger.new($stdout), config: {}, num_processes: 1)
|
19
19
|
require 'sidekiq/cli'
|
20
|
-
|
21
20
|
@reload_sidekiq = false
|
22
21
|
@exit_loader = false
|
23
22
|
@loader_pid = ::Process.pid
|
@@ -28,6 +27,8 @@ module Sidekiq
|
|
28
27
|
@loop_delay = config[:loop_delay] || 0.5
|
29
28
|
@deployer = deployer
|
30
29
|
@sidekiq_app = sidekiq_app
|
30
|
+
@num_processes = num_processes || 1
|
31
|
+
@sidekiq_pids = []
|
31
32
|
end
|
32
33
|
|
33
34
|
def run
|
@@ -46,7 +47,7 @@ module Sidekiq
|
|
46
47
|
rescue StandardError => e
|
47
48
|
log "Error in sidekiq loader: #{e.message}"
|
48
49
|
log e.backtrace.join("\n")
|
49
|
-
stop_sidekiq(@
|
50
|
+
stop_sidekiq(@sidekiq_pids)
|
50
51
|
::Process.waitall
|
51
52
|
exit 1
|
52
53
|
end
|
@@ -62,12 +63,12 @@ module Sidekiq
|
|
62
63
|
reload_app { deployer.deploy(source: deployer.archive_file) }
|
63
64
|
elsif reload_sidekiq
|
64
65
|
reload_app
|
65
|
-
elsif process_died?(@sidekiq_pid)
|
66
|
-
fork_sidekiq
|
67
66
|
end
|
67
|
+
@sidekiq_pids = running_pids(@sidekiq_pids)
|
68
|
+
fork_sidekiq(@num_processes - @sidekiq_pids.length) if @sidekiq_pids.length < @num_processes
|
68
69
|
next unless exit_loader
|
69
70
|
|
70
|
-
stop_sidekiq(@
|
71
|
+
stop_sidekiq(@sidekiq_pids)
|
71
72
|
break
|
72
73
|
end
|
73
74
|
end
|
@@ -80,30 +81,32 @@ module Sidekiq
|
|
80
81
|
end
|
81
82
|
|
82
83
|
def reload_app
|
83
|
-
quiet_sidekiq(@
|
84
|
+
quiet_sidekiq(@sidekiq_pids)
|
84
85
|
|
85
86
|
yield if block_given?
|
86
87
|
|
87
|
-
stop_sidekiq(@
|
88
|
+
stop_sidekiq(@sidekiq_pids)
|
88
89
|
|
89
90
|
# wait for sidekiq to stop
|
90
91
|
::Process.waitall
|
91
|
-
|
92
92
|
fork_sidekiq
|
93
93
|
@reload_sidekiq = false
|
94
94
|
end
|
95
95
|
|
96
|
-
def fork_sidekiq
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
96
|
+
def fork_sidekiq(num_children = @num_processes)
|
97
|
+
num_children.times do
|
98
|
+
pid = ::Process.fork do
|
99
|
+
cli = Sidekiq::CLI.instance
|
100
|
+
args = @sidekiq_app ? ['-r', @sidekiq_app] : []
|
101
|
+
cli.parse(args)
|
102
|
+
cli.run
|
103
|
+
rescue StandardError => e
|
104
|
+
message = "Error loading sidekiq process: #{e.message}"
|
105
|
+
log message
|
106
|
+
log e.backtrace.join("\n")
|
107
|
+
raise message
|
108
|
+
end
|
109
|
+
@sidekiq_pids << pid
|
107
110
|
end
|
108
111
|
end
|
109
112
|
|
@@ -126,32 +129,41 @@ module Sidekiq
|
|
126
129
|
when USR2
|
127
130
|
@reload_sidekiq = true
|
128
131
|
when TTIN
|
129
|
-
|
132
|
+
@sidekiq_pids.each do |pid|
|
133
|
+
::Process.kill(signal, pid)
|
134
|
+
end
|
130
135
|
when TERM, INT
|
131
136
|
@exit_loader = true
|
132
137
|
end
|
133
138
|
end
|
134
139
|
|
135
140
|
def debug_handler(signal)
|
136
|
-
log_data = { signal:, current_pid: ::Process.pid, loader_pid: @loader_pid,
|
141
|
+
log_data = { signal:, current_pid: ::Process.pid, loader_pid: @loader_pid, sidekiq_pids: @sidekiq_pids,
|
137
142
|
reload_sidekiq: @reload_sidekiq, exit_loader: @exit_loader }
|
138
143
|
puts "handle_signal called with #{log_data}"
|
139
144
|
end
|
140
145
|
|
141
|
-
def stop_sidekiq(
|
142
|
-
|
146
|
+
def stop_sidekiq(pids)
|
147
|
+
pids.each do |pid|
|
148
|
+
::Process.kill(TERM, pid)
|
149
|
+
end
|
150
|
+
@sidekiq_pids = []
|
143
151
|
end
|
144
152
|
|
145
|
-
def quiet_sidekiq(
|
146
|
-
|
153
|
+
def quiet_sidekiq(pids)
|
154
|
+
pids.each do |pid|
|
155
|
+
::Process.kill(TSTP, pid)
|
156
|
+
end
|
147
157
|
end
|
148
158
|
|
149
|
-
def
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
159
|
+
def running_pids(pids)
|
160
|
+
new_pids = []
|
161
|
+
pids.each do |pid|
|
162
|
+
new_pids << pid unless ::Process.waitpid(pid, ::Process::WNOHANG)
|
163
|
+
rescue Errno::ECHILD
|
164
|
+
log "PID #{pid} does not exist."
|
165
|
+
end
|
166
|
+
new_pids
|
155
167
|
end
|
156
168
|
|
157
169
|
def log(message)
|
data/sidekiq-redeploy.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.require_paths = ['lib']
|
34
34
|
|
35
35
|
spec.add_dependency 'puma-redeploy', '~> 0.3.3'
|
36
|
-
spec.add_dependency 'sidekiq', '
|
36
|
+
spec.add_dependency 'sidekiq', '>= 6', '< 8'
|
37
37
|
|
38
38
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
39
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-redeploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbeauvais
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puma-redeploy
|
@@ -28,16 +28,22 @@ dependencies:
|
|
28
28
|
name: sidekiq
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6'
|
34
|
+
- - "<"
|
32
35
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
36
|
+
version: '8'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '6'
|
44
|
+
- - "<"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
46
|
+
version: '8'
|
41
47
|
description: Sidekiq launcher to redeploy and reload app from a remote artifact. This
|
42
48
|
will detect app changes, once detected a new artifact will be pulled and the Sidekiq
|
43
49
|
app will be reloaded.
|