magic_recipes_two 0.0.94 → 0.0.95
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/capistrano/magic_recipes/sidekiq_helpers.rb +66 -0
- data/lib/capistrano/magic_recipes/version.rb +1 -1
- data/lib/capistrano/tasks/monit.rake +94 -31
- data/lib/capistrano/tasks/sidekiq_six.rake +4 -51
- data/lib/capistrano/tasks/thin_sysd.rake +1 -0
- data/lib/generators/capistrano/magic_recipes/templates/monit/alert_slack.erb +2 -0
- data/lib/generators/capistrano/magic_recipes/templates/monit/file_checks.erb +12 -0
- data/lib/generators/capistrano/magic_recipes/templates/monit/monitrc.erb +11 -21
- data/lib/generators/capistrano/magic_recipes/templates/monit/nginx.erb +3 -3
- data/lib/generators/capistrano/magic_recipes/templates/monit/pm2.erb +11 -8
- data/lib/generators/capistrano/magic_recipes/templates/monit/postgresql.erb +3 -3
- data/lib/generators/capistrano/magic_recipes/templates/monit/pwa.erb +1 -1
- data/lib/generators/capistrano/magic_recipes/templates/monit/redis.erb +3 -3
- data/lib/generators/capistrano/magic_recipes/templates/monit/sidekiq.erb +5 -5
- data/lib/generators/capistrano/magic_recipes/templates/monit/sidekiq_six.erb +19 -0
- data/lib/generators/capistrano/magic_recipes/templates/monit/thin.erb +5 -5
- data/lib/generators/capistrano/magic_recipes/templates/monit/thin_sysd.erb +17 -0
- data/lib/generators/capistrano/magic_recipes/templates/monit/website.erb +4 -4
- data/lib/generators/capistrano/magic_recipes/templates/monit/website_checks.erb +25 -0
- data/lib/generators/capistrano/magic_recipes/templates/nginx_monit.conf.erb +0 -2
- data/lib/generators/capistrano/magic_recipes/templates/sidekiq.docu-service.erb +6 -0
- data/lib/generators/capistrano/magic_recipes/templates/sidekiq.service.erb +6 -0
- data/lib/generators/capistrano/magic_recipes/templates/thin.service.erb +6 -0
- metadata +8 -5
- data/lib/capistrano/tasks/monit_sidekiq.rake +0 -44
- data/lib/generators/capistrano/magic_recipes/templates/monit/nginx_conf.erb +0 -14
- data/lib/generators/capistrano/magic_recipes/templates/monit/websiteX.erb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6cc995232184811a31e0138cb4fe99cd50099db4af9f88e8788f9cb60c009a0
|
4
|
+
data.tar.gz: c4b44eedfced7af031ddc139b02c542fce6d883ca2c20d6de90b94f66fe28db3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daeb145647e4c9ff534d4d034eea9eab3bd58bc1fa148adc74b3ff0a9a7a495bff25d487838b584413dc62bb0a917082cb6f80f09bc5761808fa5a56120507fb
|
7
|
+
data.tar.gz: 84f68613626eacb0109566a8e05e3283ee52ec9495dc1d37d76280a86bf0b2c7e14906b81d72c6b18b8b37fd4b0af59428a3997015ca832c9cb94c63c033ab3e
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module MagicRecipes
|
3
|
+
module SidekiqHelpers
|
4
|
+
|
5
|
+
|
6
|
+
def for_each_process(reverse = false, &block)
|
7
|
+
pids = processes_deamones
|
8
|
+
pids.reverse! if reverse
|
9
|
+
pids.each_with_index do |service_file, idx|
|
10
|
+
within fetch(:sidekiq_six_deamon_path) do
|
11
|
+
yield(service_file, idx)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def processes_deamones
|
17
|
+
deamons = []
|
18
|
+
if fetch(:sidekiq_six_special_queues)
|
19
|
+
fetch(:sidekiq_six_queued_processes, []).each do |qp|
|
20
|
+
counter = (qp[:processes] && qp[:processes].to_i > 0 ? qp[:processes].to_i : 1)
|
21
|
+
if counter > 1
|
22
|
+
counter.times do |idx|
|
23
|
+
deamons.push "#{ fetch(:sidekiq_six_deamon_file) }-#{ qp[:queue] }-#{ idx }"
|
24
|
+
end
|
25
|
+
else
|
26
|
+
deamons.push "#{ fetch(:sidekiq_six_deamon_file) }-#{ qp[:queue] }"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
else
|
30
|
+
counter = fetch(:sidekiq_six_processes).to_i
|
31
|
+
if counter > 1
|
32
|
+
counter.times do |idx|
|
33
|
+
deamons.push "#{ fetch(:sidekiq_six_deamon_file) }-#{ idx }"
|
34
|
+
end
|
35
|
+
else
|
36
|
+
deamons.push "#{ fetch(:sidekiq_six_deamon_file) }"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
deamons
|
40
|
+
end
|
41
|
+
|
42
|
+
def sidekiq_special_config(idx)
|
43
|
+
if fetch(:sidekiq_six_special_queues)
|
44
|
+
settingz = []
|
45
|
+
fetch(:sidekiq_six_queued_processes).each do |that|
|
46
|
+
(that[:processes] && that[:processes].to_i > 0 ? that[:processes].to_i : 1 ).to_i.times do
|
47
|
+
sttng_hash = {}
|
48
|
+
sttng_hash[:queue] = that[:queue] ? that[:queue] : "default"
|
49
|
+
sttng_hash[:concurrency] = that[:worker] && that[:worker].to_i > 0 ? that[:worker].to_i : 7
|
50
|
+
settingz.push( sttng_hash )
|
51
|
+
end
|
52
|
+
end
|
53
|
+
settingz[ idx.to_i ]
|
54
|
+
else
|
55
|
+
{}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'capistrano/magic_recipes/base_helpers'
|
2
|
+
require 'capistrano/magic_recipes/sidekiq_helpers'
|
3
|
+
include Capistrano::MagicRecipes::SidekiqHelpers
|
2
4
|
include Capistrano::MagicRecipes::BaseHelpers
|
3
5
|
|
4
6
|
namespace :load do
|
@@ -10,11 +12,10 @@ namespace :load do
|
|
10
12
|
set :monit_logfile, -> { "#{shared_path}/log/monit.log" }
|
11
13
|
set :monit_idfile, -> { '/var/lib/monit/id' }
|
12
14
|
set :monit_statefile, -> { '/var/lib/monit/state' }
|
13
|
-
set :monit_downgrade_on_deploy, -> { false }
|
14
15
|
## Status
|
15
16
|
set :monit_active, -> { true }
|
16
17
|
set :monit_main_rc, -> { true }
|
17
|
-
# set :monit_processes, -> { %w[nginx pm2 postgresql pwa redis sidekiq thin website
|
18
|
+
# set :monit_processes, -> { %w[nginx pm2 postgresql pwa redis sidekiq thin website website_checks file_checks] }
|
18
19
|
set :monit_processes, -> { %w[nginx postgresql thin website] }
|
19
20
|
set :monit_name, -> { "#{ fetch(:application) }_#{ fetch(:stage) }" }
|
20
21
|
## Mailer
|
@@ -28,24 +29,22 @@ namespace :load do
|
|
28
29
|
set :monit_mail_reply_to, -> { "support@foo.bar" }
|
29
30
|
set :monit_ignore, -> { [] } # %w[action pid]
|
30
31
|
## Additional stuff for postrgres
|
31
|
-
set :
|
32
|
-
set :postgresql_pid, -> { "/var/run/postgresql/9.1-main.pid" }
|
32
|
+
set :monit_pg_pid, -> { "/var/run/postgresql/12-main.pid" }
|
33
33
|
## Additional stuff for thin (need secrets_key_base to be set)
|
34
34
|
set :monit_thin_totalmem_mb, -> { 300 }
|
35
|
+
set :monit_thin_pid_path, -> { fetch(:thin_pid_path, "/home/#{fetch(:user)}/run") }
|
36
|
+
set :thin_sysd_roles, -> { fetch(:thin_roles) }
|
35
37
|
## Additional stuff for sidekiq (need secrets_key_base to be set)
|
36
38
|
set :monit_sidekiq_totalmem_mb, -> { 300 }
|
37
39
|
set :monit_sidekiq_timeout_sec, -> { 90 }
|
40
|
+
set :monit_sidekiq_pid_path, -> { fetch(:sidekiq_six_pid_path, "/home/#{fetch(:user)}/run") }
|
38
41
|
## Additional App helpers
|
39
42
|
set :monit_app_worker_command, -> { "cd #{ current_path } ; #{fetch(:rvm_path)}/bin/rvm #{fetch(:rvm_ruby_version)} do bundle exec MONIT_CMD" }
|
40
43
|
set :monit_app_worker_role, -> { :user } # user / bash / shell
|
41
44
|
set :monit_app_worker_prefix, -> { :rvm } # rvm / rvm1capistrano3 / env
|
42
45
|
## WebClient
|
43
46
|
set :monit_http_client, -> { true }
|
44
|
-
set :monit_http_domain, -> { false }
|
45
47
|
set :monit_http_port, -> { 2812 }
|
46
|
-
set :monit_http_use_ssl, -> { false }
|
47
|
-
set :monit_http_allow_self_certification, -> { false }
|
48
|
-
set :monit_http_pemfile, -> { "/etc/monit/monit.pem" }
|
49
48
|
set :monit_http_username, -> { "admin" }
|
50
49
|
set :monit_http_password, -> { "monitor" }
|
51
50
|
# use a subdomain for monit?
|
@@ -56,23 +55,16 @@ namespace :load do
|
|
56
55
|
set :monit_webclient_ssl_key, -> { false }
|
57
56
|
set :monit_nginx_template, -> { :default }
|
58
57
|
## Website
|
58
|
+
set :monit_website_check_name, -> { "#{fetch(:application)}-#{fetch(:stage)}" }
|
59
59
|
set :monit_website_check_timeout, -> { 10 }
|
60
60
|
set :monit_website_check_cycles, -> { 3 }
|
61
61
|
set :monit_website_check_content, -> { false }
|
62
62
|
set :monit_website_check_path, -> { "/" }
|
63
63
|
set :monit_website_check_text, -> { "<!DOCTYPE html>" }
|
64
|
-
##
|
65
|
-
set :
|
66
|
-
|
67
|
-
|
68
|
-
set :monit_website2_check_path, -> { "/" }
|
69
|
-
set :monit_website2_check_text, -> { "<!DOCTYPE html>" }
|
70
|
-
## Website3
|
71
|
-
set :monit_website3_check_domains, -> { [] }
|
72
|
-
set :monit_website3_check_ssl, -> { false }
|
73
|
-
set :monit_website3_check_content, -> { false }
|
74
|
-
set :monit_website3_check_path, -> { "/" }
|
75
|
-
set :monit_website3_check_text, -> { "<!DOCTYPE html>" }
|
64
|
+
## check other Sites:
|
65
|
+
set :monit_websites_to_check, -> { [] }
|
66
|
+
# Website: { name: String, domain: String, ssl: Boolean, check_content: Boolean, path: String, content: String }
|
67
|
+
|
76
68
|
## M/Monit
|
77
69
|
set :monit_mmonit_url, -> { false }
|
78
70
|
|
@@ -83,12 +75,23 @@ namespace :load do
|
|
83
75
|
set :monit_pm2_pid_path, -> { "/home/#{fetch(:user)}/.pm2/pids" }
|
84
76
|
set :monit_pm2_start_script, -> { "ecosystem.config.js" }
|
85
77
|
set :monit_pm2_stage, -> { "production" }
|
86
|
-
set :monit_pm2_website, -> { "example.com" }
|
87
|
-
set :monit_pm2_website_ssl, -> { false }
|
88
78
|
set :pm2_roles, -> { :web }
|
89
79
|
set :monit_pm2_worker_role, -> { :user }
|
90
80
|
set :monit_pm2_worker_prefix, -> { "" }
|
81
|
+
set :monit_pm2_check_website, -> { false }
|
82
|
+
set :monit_pm2_website_name, -> { "PM2 #{fetch(:application)} #{fetch(:stage)}" }
|
83
|
+
set :monit_pm2_website_url, -> { "example.com" }
|
84
|
+
set :monit_pm2_website_ssl, -> { false }
|
85
|
+
|
91
86
|
|
87
|
+
## Check files
|
88
|
+
set :monit_files_to_check, -> { [] }
|
89
|
+
## FILE: { name: String, path: String, max_size: Integer, clear: Boolean }
|
90
|
+
|
91
|
+
## Slack Alerts
|
92
|
+
set :monit_use_slack, -> { false }
|
93
|
+
set :monit_slack_webhook, -> { "" } # your Slack webhook URL
|
94
|
+
set :monit_slack_bin_path, -> { "/etc/monit/alert_slack.sh" }
|
92
95
|
|
93
96
|
end
|
94
97
|
end
|
@@ -115,8 +118,8 @@ namespace :monit do
|
|
115
118
|
# invoke "monit:redis"
|
116
119
|
# invoke "monit:thin"
|
117
120
|
# invoke "monit:configure_website"
|
118
|
-
%w[nginx pm2 postgresql pwa redis sidekiq thin website
|
119
|
-
invoke "monit
|
121
|
+
%w[nginx pm2 postgresql pwa redis sidekiq sidekiq_six thin thin_sysd website website_checks file_checks].each do |command|
|
122
|
+
invoke "monit:#{command}:configure" if Array(fetch(:monit_processes)).include?(command)
|
120
123
|
end
|
121
124
|
if fetch(:monit_webclient, false) && fetch(:monit_webclient_domain, false)
|
122
125
|
invoke "nginx:monit:add"
|
@@ -135,7 +138,7 @@ namespace :monit do
|
|
135
138
|
end
|
136
139
|
end
|
137
140
|
|
138
|
-
%w[nginx pm2 postgresql redis sidekiq thin].each do |process|
|
141
|
+
%w[nginx pm2 postgresql redis sidekiq sidekiq_six thin thin_sysd].each do |process|
|
139
142
|
namespace process.to_sym do
|
140
143
|
|
141
144
|
%w[monitor unmonitor start stop restart].each do |command|
|
@@ -174,10 +177,12 @@ namespace :monit do
|
|
174
177
|
end
|
175
178
|
end
|
176
179
|
end
|
177
|
-
elsif %w[pm2 pwa sidekiq thin].include?(process)
|
180
|
+
elsif %w[pm2 pwa sidekiq thin sidekiq_six thin_sysd].include?(process)
|
178
181
|
## App specific tasks (unique for app and environment)
|
179
182
|
desc "Upload Monit #{process} config file (app specific)"
|
180
183
|
task "configure" do
|
184
|
+
puts "configure: #{process}"
|
185
|
+
puts ":monit_processes: #{ Array(fetch(:monit_processes)) }"
|
181
186
|
if Array(fetch(:monit_processes)).include?(process)
|
182
187
|
on release_roles fetch("#{process}_roles".to_sym) do |role|
|
183
188
|
monit_config process, "/etc/monit/conf.d/#{fetch(:application)}_#{fetch(:stage)}_#{process}.conf", role
|
@@ -189,14 +194,13 @@ namespace :monit do
|
|
189
194
|
end
|
190
195
|
end
|
191
196
|
|
192
|
-
%w[pwa website
|
197
|
+
%w[pwa website website_checks file_checks].each do |process|
|
193
198
|
namespace process.to_sym do
|
194
199
|
|
195
200
|
desc "Upload Monit #{process} config file (app specific)"
|
196
|
-
task "
|
201
|
+
task "configure" do
|
197
202
|
if Array(fetch(:monit_processes)).include?(process)
|
198
|
-
on release_roles fetch("#{process =~
|
199
|
-
process_file = process =~ /^website\d{1}$/ ? 'websiteX' : process
|
203
|
+
on release_roles fetch("#{process =~ /^website|file/ ? 'nginx' : process}_roles".to_sym, :web) do |role|
|
200
204
|
monit_config process, "/etc/monit/conf.d/#{fetch(:application)}_#{fetch(:stage)}_#{process}.conf", role
|
201
205
|
end
|
202
206
|
end
|
@@ -206,6 +210,19 @@ namespace :monit do
|
|
206
210
|
end
|
207
211
|
|
208
212
|
|
213
|
+
namespace :slack do
|
214
|
+
desc 'Downgrade MONIT to 5.16 (fix action problem)'
|
215
|
+
task :configure do
|
216
|
+
on roles :db do
|
217
|
+
on release_roles fetch(:monit_roles) do |role|
|
218
|
+
monit_config 'alert_slack', "#{ fetch(:monit_slack_bin_path) }", role
|
219
|
+
execute :sudo, "chmod +x #{ fetch(:monit_slack_bin_path) }"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
|
209
226
|
|
210
227
|
|
211
228
|
%w[start stop restart syntax reload].each do |command|
|
@@ -221,6 +238,10 @@ namespace :monit do
|
|
221
238
|
fetch(:sidekiq_service_name, "#{fetch(:application)}_#{fetch(:stage)}_sidekiq_") + index.to_s
|
222
239
|
end
|
223
240
|
|
241
|
+
def sidekiq_six_service_name(service_file)
|
242
|
+
"#{fetch(:application)}_#{fetch(:stage)}_sidekiq_#{ service_file.split('-').last }"
|
243
|
+
end
|
244
|
+
|
224
245
|
end
|
225
246
|
|
226
247
|
def monit_config( name, destination = nil, role = nil )
|
@@ -268,6 +289,44 @@ end
|
|
268
289
|
|
269
290
|
|
270
291
|
|
292
|
+
|
293
|
+
def init_site_check_item( domain )
|
294
|
+
## defaults
|
295
|
+
that = { ssl: false, check_content: false, path: '/', content: '<!DOCTYPE html>', timeout: 30, cycles: 3 }
|
296
|
+
that.merge! domain
|
297
|
+
that[:name] = that[:domain] if [nil, '', ' '].include?( that[:name] )
|
298
|
+
that
|
299
|
+
end
|
300
|
+
|
301
|
+
def init_file_check_item( file )
|
302
|
+
## defaults
|
303
|
+
that = { name: '', path: '', max_size: 12, clear: false }
|
304
|
+
that.merge! file
|
305
|
+
that[:name] = that[:path].to_s.split('/').last if [nil, '', ' '].include?( that[:name] )
|
306
|
+
that
|
307
|
+
end
|
308
|
+
|
309
|
+
def monit_website_list
|
310
|
+
Array( fetch(:monit_websites_to_check) ).map{ |x| init_site_check_item(x) }
|
311
|
+
end
|
312
|
+
|
313
|
+
def monit_files_list
|
314
|
+
Array( fetch(:monit_files_to_check) ).map{ |x| init_file_check_item(x) }
|
315
|
+
end
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
def monit_alert
|
320
|
+
if fetch(:monit_use_slack, false)
|
321
|
+
"exec #{fetch(:monit_slack_bin_path)} and repeat every 3 cycles"
|
322
|
+
else
|
323
|
+
"alert"
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
271
330
|
namespace :nginx do
|
272
331
|
namespace :monit do
|
273
332
|
|
@@ -316,7 +375,11 @@ namespace :lets_encrypt do
|
|
316
375
|
desc "Generate MONIT-WebClient LetsEncrypt certificate"
|
317
376
|
task :monit_certonly do
|
318
377
|
on release_roles fetch(:lets_encrypt_roles) do
|
319
|
-
|
378
|
+
if fetch(:lets_encrypt_client) == "certbot-auto"
|
379
|
+
execute :sudo, "#{ fetch(:lets_encrypt_path) }/certbot-auto --non-interactive --agree-tos --email #{fetch(:lets_encrypt_email)} certonly --webroot -w #{current_path}/public -d #{ fetch(:monit_webclient_domain).gsub(/^\*?\./, '') }"
|
380
|
+
else
|
381
|
+
execute :sudo, "certbot --non-interactive --agree-tos --email #{fetch(:lets_encrypt_email)} certonly --webroot -w #{current_path}/public -d #{ fetch(:monit_webclient_domain).gsub(/^\*?\./, '') }"
|
382
|
+
end
|
320
383
|
end
|
321
384
|
end
|
322
385
|
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'capistrano/magic_recipes/sidekiq_helpers'
|
2
|
+
include Capistrano::MagicRecipes::SidekiqHelpers
|
3
|
+
|
1
4
|
##
|
2
5
|
## NEW! for sidekiqs new deamonized style
|
3
6
|
##
|
@@ -22,6 +25,7 @@ namespace :load do
|
|
22
25
|
## => [ { queue: "queue_name", processes: "count", worker: "count" }]
|
23
26
|
|
24
27
|
set :sidekiq_six_deamon_path, -> { "/lib/systemd/system" }
|
28
|
+
set :sidekiq_six_pid_path, -> { "/home/#{fetch(:user)}/run" }
|
25
29
|
set :sidekiq_six_deamon_template, -> { :default }
|
26
30
|
|
27
31
|
set :sidekiq_six_ruby_vm, -> { :system } # ( :rvm | :rbenv | :system )
|
@@ -35,58 +39,7 @@ end
|
|
35
39
|
|
36
40
|
namespace :sidekiq_six do
|
37
41
|
|
38
|
-
def for_each_process(reverse = false, &block)
|
39
|
-
pids = processes_deamones
|
40
|
-
pids.reverse! if reverse
|
41
|
-
pids.each_with_index do |service_file, idx|
|
42
|
-
within fetch(:sidekiq_six_deamon_path) do
|
43
|
-
yield(service_file, idx)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
42
|
|
48
|
-
def processes_deamones
|
49
|
-
deamons = []
|
50
|
-
if fetch(:sidekiq_six_special_queues)
|
51
|
-
fetch(:sidekiq_six_queued_processes, []).each do |qp|
|
52
|
-
counter = (qp[:processes] && qp[:processes].to_i > 0 ? qp[:processes].to_i : 1)
|
53
|
-
if counter > 1
|
54
|
-
counter.times do |idx|
|
55
|
-
deamons.push "#{ fetch(:sidekiq_six_deamon_file) }-#{ qp[:queue] }-#{ idx }"
|
56
|
-
end
|
57
|
-
else
|
58
|
-
deamons.push "#{ fetch(:sidekiq_six_deamon_file) }-#{ qp[:queue] }"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
else
|
62
|
-
counter = fetch(:sidekiq_six_processes).to_i
|
63
|
-
if counter > 1
|
64
|
-
counter.times do |idx|
|
65
|
-
deamons.push "#{ fetch(:sidekiq_six_deamon_file) }-#{ idx }"
|
66
|
-
end
|
67
|
-
else
|
68
|
-
deamons.push "#{ fetch(:sidekiq_six_deamon_file) }"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
deamons
|
72
|
-
end
|
73
|
-
|
74
|
-
def sidekiq_special_config(idx)
|
75
|
-
if fetch(:sidekiq_six_special_queues)
|
76
|
-
settingz = []
|
77
|
-
fetch(:sidekiq_six_queued_processes).each do |that|
|
78
|
-
(that[:processes] && that[:processes].to_i > 0 ? that[:processes].to_i : 1 ).to_i.times do
|
79
|
-
sttng_hash = {}
|
80
|
-
sttng_hash[:queue] = that[:queue] ? that[:queue] : "default"
|
81
|
-
sttng_hash[:concurrency] = that[:worker] && that[:worker].to_i > 0 ? that[:worker].to_i : 7
|
82
|
-
settingz.push( sttng_hash )
|
83
|
-
end
|
84
|
-
end
|
85
|
-
settingz[ idx.to_i ]
|
86
|
-
else
|
87
|
-
{}
|
88
|
-
end
|
89
|
-
end
|
90
43
|
|
91
44
|
def upload_deamon(service_file, idx = 0)
|
92
45
|
args = []
|
@@ -21,6 +21,7 @@ namespace :load do
|
|
21
21
|
set :thin_daemon_ruby_vm, -> { :system } # ( :rvm | :rbenv | :system )
|
22
22
|
set :thin_daemon_file, -> { "thin_#{fetch(:application)}_#{fetch(:stage)}" }
|
23
23
|
set :thin_daemon_path, -> { "/lib/systemd/system" }
|
24
|
+
set :thin_pid_path, -> { "/home/#{fetch(:user)}/run" }
|
24
25
|
set :thin_daemon_template, -> { :default }
|
25
26
|
set :thin_daemon_log_lines, -> { 100 }
|
26
27
|
set :thin_daemon_user, -> { fetch(:user, 'deploy') } # role-user
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Check files for <%= fetch(:application) %> [<%= fetch(:stage) %>]
|
2
|
+
<% monit_files_list.each do |that| %>
|
3
|
+
check file "<%= that[:name] %>" with path <%= that[:path] %>
|
4
|
+
if size > <%= that[:max_size].to_i %> GB then <%= monit_alert %>
|
5
|
+
<% if that[:clear] %>
|
6
|
+
if size > <%= that[:max_size].to_i %> GB
|
7
|
+
for 3 cycles
|
8
|
+
then exec '/bin/echo "cleared by MONIT - $( date +"%F - %R" ):" > <%= that[:path] %>'
|
9
|
+
repeat every 20 cycles
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<% end %>
|
@@ -28,11 +28,9 @@ set mail-format {
|
|
28
28
|
Your faithful employee,
|
29
29
|
M O N I T
|
30
30
|
|
31
|
-
<% if fetch(:
|
32
|
-
Web: <%= fetch(:
|
33
|
-
<%
|
34
|
-
Web: <%= fetch(:monit_http_use_ssl) ? "https" : "http" %>://<%= fetch(:app_server_ip) %>:<%= fetch(:monit_http_port) %>/
|
35
|
-
<% end %><% end %>
|
31
|
+
<% if fetch(:monit_webclient) %>
|
32
|
+
Web: <%= fetch(:monit_webclient_use_ssl) ? "https" : "http" %>://<%= fetch(:monit_webclient_domain) %>
|
33
|
+
<% end %>
|
36
34
|
}
|
37
35
|
|
38
36
|
set mailserver <%= fetch(:monit_mail_server) %> port <%= fetch(:monit_mail_port) %>
|
@@ -44,29 +42,21 @@ set mailserver <%= fetch(:monit_mail_server) %> port <%= fetch(:monit_mail_port)
|
|
44
42
|
|
45
43
|
set alert <%= fetch(:monit_mail_to) %><%= Array( fetch(:monit_ignore, nil) ).count > 0 ? " but not on { #{ Array( fetch(:monit_ignore, nil) ).join(", ") } }" : "" %>
|
46
44
|
|
47
|
-
<% if fetch(:
|
45
|
+
<% if fetch(:monit_webclient) %>
|
48
46
|
set httpd port <%= fetch(:monit_http_port) %>
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
# allow 127.0.0.1
|
53
|
-
<% if fetch(:monit_http_use_ssl) %>
|
54
|
-
ssl enable
|
55
|
-
pemfile <%= fetch(:monit_http_pemfile) %>
|
56
|
-
<% if fetch(:monit_http_allow_self_certification) %>
|
57
|
-
ALLOWSELFCERTIFICATION
|
58
|
-
<% end %>
|
59
|
-
<% end %>
|
47
|
+
<% if fetch(:monit_webclient_use_ssl, false) %>
|
48
|
+
allow 127.0.0.1
|
49
|
+
<% end %>
|
60
50
|
allow <%= fetch(:monit_http_username) %>:<%= fetch(:monit_http_password) %>
|
61
51
|
<% end %>
|
62
52
|
|
63
53
|
check system <%= fetch(:monit_name, "#{ fetch(:application) }_server") %>
|
64
|
-
if loadavg(5min) > 2 for 2 cycles then
|
65
|
-
if memory > 75% for 2 cycles then
|
66
|
-
if cpu(user) > 75% for 2 cycles then
|
54
|
+
if loadavg(5min) > 2 for 2 cycles then <%= monit_alert %>
|
55
|
+
if memory > 75% for 2 cycles then <%= monit_alert %>
|
56
|
+
if cpu(user) > 75% for 2 cycles then <%= monit_alert %>
|
67
57
|
|
68
58
|
check device HardDrive with path /
|
69
|
-
if SPACE usage > 75% then
|
59
|
+
if SPACE usage > 75% then <%= monit_alert %>
|
70
60
|
|
71
61
|
|
72
62
|
<% if fetch(:monit_mmonit_url, false) %>
|
@@ -3,10 +3,10 @@ check process nginx with pidfile /var/run/nginx.pid
|
|
3
3
|
start program = "/etc/init.d/nginx start"
|
4
4
|
stop program = "/etc/init.d/nginx stop"
|
5
5
|
# if does not exist then start # (default)
|
6
|
-
# if does not exist for 3 cycles then
|
7
|
-
if 3 restarts within 5 cycles then
|
6
|
+
# if does not exist for 3 cycles then <%= monit_alert %>
|
7
|
+
if 3 restarts within 5 cycles then <%= monit_alert %>
|
8
8
|
if children > 250 then restart
|
9
9
|
if failed host 127.0.0.1 port 80 then restart
|
10
|
-
if cpu is greater than 40% for 2 cycles then
|
10
|
+
if cpu is greater than 40% for 2 cycles then <%= monit_alert %>
|
11
11
|
if cpu > 60% for 5 cycles then restart
|
12
12
|
if 10 restarts within 10 cycles then timeout
|
@@ -5,19 +5,20 @@
|
|
5
5
|
start program = "<%= monit_pm2_prefixed("pm2 restart #{fetch(:monit_pm2_start_script)} --env #{fetch(:monit_pm2_stage)}") %>"
|
6
6
|
stop program = "<%= monit_pm2_prefixed("pm2 stop #{fetch(:monit_pm2_start_script)} --env #{fetch(:monit_pm2_stage)}") %>"
|
7
7
|
# if does not exist then start # (default)
|
8
|
-
if does not exist for 3 cycles then
|
9
|
-
# if 3 restarts within 10 cycles then
|
10
|
-
# if cpu > 50% then
|
8
|
+
if does not exist for 3 cycles then <%= monit_alert %>
|
9
|
+
# if 3 restarts within 10 cycles then <%= monit_alert %>
|
10
|
+
# if cpu > 50% then <%= monit_alert %>
|
11
11
|
# if cpu > 50% for 3 cycles then restart
|
12
12
|
# if 5 restarts within 15 cycles then timeout
|
13
13
|
# alert <%= fetch(:monit_mail_to) %> only on { pid }
|
14
|
-
if changed pid 3 times within 10 cycles then
|
14
|
+
if changed pid 3 times within 10 cycles then <%= monit_alert %>
|
15
15
|
<% end %>
|
16
16
|
|
17
17
|
|
18
|
-
|
18
|
+
<% if fetch(:monit_pm2_check_website, false) %>
|
19
19
|
# Check website for pm2: <%= fetch(:application) %> [<%= fetch(:stage) %>]
|
20
|
-
check host <%= fetch(:
|
20
|
+
check host "<%= fetch(:monit_pm2_website_name).gsub(/\s+/,'-').gsub(/_/,'-').gsub(/:/,'-').gsub(/--+/,'-') %>" with address <%= fetch(:monit_pm2_website_url) %>
|
21
|
+
<% if fetch(:monit_pm2_website_ssl) %>if failed port 443 protocol https and certificate valid > 2 days then <%= monit_alert %><% end %>
|
21
22
|
if failed
|
22
23
|
<% if fetch(:monit_pm2_website_ssl) %>
|
23
24
|
port 443
|
@@ -27,6 +28,8 @@ check host <%= fetch(:monit_pm2_website) %> with address <%= fetch(:monit_pm2_we
|
|
27
28
|
port 80
|
28
29
|
protocol http
|
29
30
|
<% end %>
|
30
|
-
|
31
|
+
status = 200
|
31
32
|
with timeout 13 seconds for 5 cycles
|
32
|
-
then
|
33
|
+
then <%= monit_alert %>
|
34
|
+
|
35
|
+
<% end %>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Monit configuration for POSTGRESQL : <%= fetch(:application) %>
|
2
|
-
check process postgresql with pidfile <%= fetch(:
|
2
|
+
check process postgresql with pidfile <%= fetch(:monit_pg_pid) %>
|
3
3
|
start program = "/etc/init.d/postgresql start"
|
4
4
|
stop program = "/etc/init.d/postgresql stop"
|
5
5
|
# if does not exist then start # (default)
|
6
|
-
# if does not exist for 3 cycles then
|
7
|
-
if 3 restarts within 5 cycles then
|
6
|
+
# if does not exist for 3 cycles then <%= monit_alert %>
|
7
|
+
if 3 restarts within 5 cycles then <%= monit_alert %>
|
8
8
|
if failed host localhost port 5432 protocol pgsql then restart
|
9
9
|
if 5 restarts within 5 cycles then timeout
|
@@ -3,9 +3,9 @@ check process redis with pidfile <%= fetch(:redis_pid) %>
|
|
3
3
|
start program = "/etc/init.d/redis-server start"
|
4
4
|
stop program = "/etc/init.d/redis-server stop"
|
5
5
|
# if does not exist then start # (default)
|
6
|
-
# if does not exist for 3 cycles then
|
7
|
-
if 3 restarts within 5 cycles then
|
8
|
-
if totalmem > 100 Mb then
|
6
|
+
# if does not exist for 3 cycles then <%= monit_alert %>
|
7
|
+
if 3 restarts within 5 cycles then <%= monit_alert %>
|
8
|
+
if totalmem > 100 Mb then <%= monit_alert %>
|
9
9
|
if children > 255 for 5 cycles then stop
|
10
10
|
if cpu usage > 95% for 3 cycles then restart
|
11
11
|
if failed host 127.0.0.1 port 6379 then restart
|
@@ -31,12 +31,12 @@ check process <%= sidekiq_service_name(idx) %>
|
|
31
31
|
stop program = "<%= monit_app_prefixed("sidekiqctl stop #{ pid_file }") %>" with timeout <%= fetch(:monit_sidekiq_timeout_sec, 90) %> seconds
|
32
32
|
group sidekiq-<%= fetch(:sidekiq_monit_group, fetch(:application)) %>-<%= fetch(:stage) %>
|
33
33
|
# if does not exist then start # (default)
|
34
|
-
if totalmem > <%= ( fetch( :monit_sidekiq_totalmem_mb, 300 ).to_i * 0.75 ).to_i %> MB then
|
34
|
+
if totalmem > <%= ( fetch( :monit_sidekiq_totalmem_mb, 300 ).to_i * 0.75 ).to_i %> MB then <%= monit_alert %>
|
35
35
|
if totalmem > <%= fetch( :monit_sidekiq_totalmem_mb, 300 ) %> MB for 2 cycles then restart
|
36
|
-
# if does not exist for 3 cycles then
|
36
|
+
# if does not exist for 3 cycles then <%= monit_alert %>
|
37
37
|
# alert <%= fetch(:monit_mail_to) %> only on { pid }
|
38
|
-
if 3 restarts within 5 cycles then
|
38
|
+
if 3 restarts within 5 cycles then <%= monit_alert %>
|
39
39
|
if 3 restarts within 5 cycles then timeout
|
40
|
-
if 2 restarts within 3 cycles then
|
41
|
-
if changed pid 2 times within 10 cycles then
|
40
|
+
if 2 restarts within 3 cycles then <%= monit_alert %>
|
41
|
+
if changed pid 2 times within 10 cycles then <%= monit_alert %>
|
42
42
|
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Monit configuration for SIDEKIQ-six : <%= fetch(:application) %> (<%= fetch(:stage) %>)
|
2
|
+
<% for_each_process do |service_file, idx| %>
|
3
|
+
|
4
|
+
CHECK process <%= sidekiq_six_service_name(service_file) %> with pidfile <%= fetch(:monit_sidekiq_pid_path) %>/<%= service_file %>.pid
|
5
|
+
start program = "/bin/systemctl start <%= service_file %>" with timeout <%= fetch(:monit_sidekiq_timeout_sec, 90) %> seconds
|
6
|
+
stop program = "/bin/systemctl stop <%= service_file %>" with timeout <%= fetch(:monit_sidekiq_timeout_sec, 90) %> seconds
|
7
|
+
GROUP sidekiq-<%= fetch(:sidekiq_monit_group, fetch(:application)) %>-<%= fetch(:stage) %>
|
8
|
+
GROUP sidekiq
|
9
|
+
# if does not exist then start # (default)
|
10
|
+
if totalmem > <%= ( fetch( :monit_sidekiq_totalmem_mb, 300 ).to_i * 0.75 ).to_i %> MB then <%= monit_alert %>
|
11
|
+
if totalmem > <%= fetch( :monit_sidekiq_totalmem_mb, 300 ) %> MB for 2 cycles then restart
|
12
|
+
# if does not exist for 3 cycles then <%= monit_alert %>
|
13
|
+
# alert <%= fetch(:monit_mail_to) %> only on { pid }
|
14
|
+
if 3 restarts within 5 cycles then <%= monit_alert %>
|
15
|
+
if 3 restarts within 5 cycles then timeout
|
16
|
+
if 2 restarts within 3 cycles then <%= monit_alert %>
|
17
|
+
if changed pid 2 times within 10 cycles then <%= monit_alert %>
|
18
|
+
|
19
|
+
<% end %>
|
@@ -5,13 +5,13 @@
|
|
5
5
|
start program = "<%= monit_app_prefixed("thin start -C config/thin_app_#{ fetch(:stage) }.yml -o #{ n }") %>"
|
6
6
|
stop program = "<%= monit_app_prefixed("thin stop -C config/thin_app_#{ fetch(:stage) }.yml -o #{ n }") %>"
|
7
7
|
# if does not exist then start # (default)
|
8
|
-
# if does not exist for 3 cycles then
|
9
|
-
if 3 restarts within 5 cycles then
|
10
|
-
if mem > <%= ( fetch( :monit_thin_totalmem_mb, 300 ).to_i * 0.75 ).to_i %> MB then
|
8
|
+
# if does not exist for 3 cycles then <%= monit_alert %>
|
9
|
+
if 3 restarts within 5 cycles then <%= monit_alert %>
|
10
|
+
if mem > <%= ( fetch( :monit_thin_totalmem_mb, 300 ).to_i * 0.75 ).to_i %> MB then <%= monit_alert %>
|
11
11
|
if mem > <%= fetch( :monit_thin_totalmem_mb, 300 ) %> MB for 2 cycles then restart
|
12
|
-
if cpu > 50% then
|
12
|
+
if cpu > 50% then <%= monit_alert %>
|
13
13
|
if cpu > 50% for 3 cycles then restart
|
14
14
|
if 5 restarts within 5 cycles then timeout
|
15
15
|
# alert <%= fetch(:monit_mail_to) %> only on { pid }
|
16
|
-
if changed pid 2 times within 20 cycles then
|
16
|
+
if changed pid 2 times within 20 cycles then <%= monit_alert %>
|
17
17
|
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Monit configuration for THIN : <%= fetch(:application) %> (<%= fetch(:stage) %>)
|
2
|
+
<% fetch(:app_instances, 1).times do |n| %>
|
3
|
+
check process <%= fetch(:application) %>_<%= fetch(:stage) %>_thin_<%= n %> with pidfile <%= deploy_to %>/shared/pids/thin_<%= fetch(:application) %>_<%= fetch(:stage) %>.<%= n %>.pid
|
4
|
+
group thin-<%= fetch(:application) %>-<%= fetch(:stage) %>
|
5
|
+
start program = "<%= monit_app_prefixed("thin start -C config/thin_app_#{ fetch(:stage) }.yml -o #{ n }") %>"
|
6
|
+
stop program = "<%= monit_app_prefixed("thin stop -C config/thin_app_#{ fetch(:stage) }.yml -o #{ n }") %>"
|
7
|
+
if does not exist for 3 cycles then start # (default)
|
8
|
+
if does not exist for 3 cycles then <%= monit_alert %>
|
9
|
+
if 3 restarts within 5 cycles then <%= monit_alert %>
|
10
|
+
if mem > <%= ( fetch( :monit_thin_totalmem_mb, 300 ).to_i * 0.75 ).to_i %> MB then <%= monit_alert %>
|
11
|
+
if mem > <%= fetch( :monit_thin_totalmem_mb, 300 ) %> MB for 2 cycles then restart
|
12
|
+
if cpu > 50% then <%= monit_alert %>
|
13
|
+
if cpu > 50% for 3 cycles then restart
|
14
|
+
if 5 restarts within 5 cycles then timeout
|
15
|
+
# alert <%= fetch(:monit_mail_to) %> only on { pid }
|
16
|
+
if changed pid 2 times within 20 cycles then <%= monit_alert %>
|
17
|
+
<% end %>
|
@@ -8,11 +8,11 @@
|
|
8
8
|
<% end %>
|
9
9
|
# Check domains on port 80 <%= "(and 443 if ssl is on)" if fetch(:nginx_use_ssl) %> for <%= fetch(:application) %> [<%= fetch(:stage) %>]
|
10
10
|
<% domain_list.uniq.each do |domain| %>
|
11
|
-
check host <%= domain %> with address <%= domain %>
|
11
|
+
check host "<%= fetch(:monit_website_check_name, domain) %>" with address <%= domain %>
|
12
|
+
<% if fetch(:nginx_use_ssl) %>if failed port 443 protocol https and certificate valid > 2 days then <%= monit_alert %><% end %>
|
12
13
|
if failed
|
13
14
|
<% if fetch(:nginx_use_ssl) %>
|
14
|
-
|
15
|
-
type TCPSSL
|
15
|
+
port 443
|
16
16
|
protocol https
|
17
17
|
<% else %>
|
18
18
|
port 80
|
@@ -25,6 +25,6 @@ check host <%= domain %> with address <%= domain %>
|
|
25
25
|
# status = 200
|
26
26
|
with timeout <%= fetch(:monit_website_check_timeout, 10) %> seconds
|
27
27
|
for <%= fetch(:monit_website_check_cycles, 3) %> cycles
|
28
|
-
|
28
|
+
then <%= monit_alert %>
|
29
29
|
<% end %>
|
30
30
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Check additional domains for <%= fetch(:application) %> [<%= fetch(:stage) %>]
|
2
|
+
<% monit_website_list.each do |that| %>
|
3
|
+
check host "<%= that[:name] %>" with address <%= that[:domain] %>
|
4
|
+
<% if that[:ssl] %>if failed port 443 protocol https and certificate valid > 2 days then <%= monit_alert %><% end %>
|
5
|
+
if failed
|
6
|
+
<% if that[:ssl] %>
|
7
|
+
port 443
|
8
|
+
type TCPSSL
|
9
|
+
protocol https
|
10
|
+
<% else %>
|
11
|
+
port 80
|
12
|
+
protocol http
|
13
|
+
<% end %>
|
14
|
+
<% if that[:check_content] %>
|
15
|
+
request "<%= that[:path] || '/' %>"
|
16
|
+
content = "<%= that[:content] %>"
|
17
|
+
<% else %>
|
18
|
+
status = 200
|
19
|
+
<% end %>
|
20
|
+
with timeout <%= that[:timeout] %> seconds
|
21
|
+
for <%= that[:cycles] %> cycles
|
22
|
+
then <%= monit_alert %>
|
23
|
+
|
24
|
+
<% end %>
|
25
|
+
|
@@ -53,6 +53,12 @@ ExecStart=/usr/local/bin/bundle exec sidekiq <%= @side_kiq_args %>
|
|
53
53
|
<% end %>
|
54
54
|
|
55
55
|
|
56
|
+
## build PID-File .. only working method :( .. (needed for monit)
|
57
|
+
ExecStartPost=/bin/bash -c '/bin/echo $MAINPID > <%= fetch(:sidekiq_six_pid_path) %>/<%= @service_file %>.pid'
|
58
|
+
ExecStopPost=/bin/bash -c 'rm <%= fetch(:sidekiq_six_pid_path) %>/<%= @service_file %>.pid'
|
59
|
+
|
60
|
+
|
61
|
+
|
56
62
|
# Use `systemctl kill -s TSTP <%= @service_file %>` to quiet the Sidekiq process
|
57
63
|
|
58
64
|
# !!! Change this to your deploy user account !!!
|
@@ -15,6 +15,12 @@ ExecStart=<%= fetch(:rvm_path) %>/bin/rvm <%= fetch(:rvm_ruby_version) %> do bun
|
|
15
15
|
ExecStart=/usr/local/bin/bundle exec sidekiq <%= @side_kiq_args %>
|
16
16
|
<% end %>
|
17
17
|
|
18
|
+
|
19
|
+
## build PID-File .. only working method :( .. (needed for monit)
|
20
|
+
ExecStartPost=/bin/bash -c '/bin/echo $MAINPID > <%= fetch(:sidekiq_six_pid_path) %>/<%= @service_file %>.pid'
|
21
|
+
ExecStopPost=/bin/bash -c 'rm <%= fetch(:sidekiq_six_pid_path) %>/<%= @service_file %>.pid'
|
22
|
+
|
23
|
+
|
18
24
|
User=<%= fetch(:sidekiq_six_user) %>
|
19
25
|
Group=<%= fetch(:sidekiq_six_user) %>
|
20
26
|
UMask=0002
|
@@ -24,6 +24,12 @@ ExecStop=/usr/local/bin/bundle exec thin -C config/thin_app_<%= fetch(:stage) %>
|
|
24
24
|
ExecReload=/usr/local/bin/bundle exec thin -C config/thin_app_<%= fetch(:stage) %>.yml restart
|
25
25
|
<% end %>
|
26
26
|
|
27
|
+
|
28
|
+
## build PID-File .. only working method :(
|
29
|
+
ExecStartPost=/bin/bash -c '/bin/echo $MAINPID > <%= fetch(:thin_pid_path) %>/thin_<%= fetch(:application) %>_<%= fetch(:stage) %>.pid'
|
30
|
+
ExecStopPost=/bin/bash -c 'rm <%= fetch(:thin_pid_path) %>/thin_<%= fetch(:application) %>_<%= fetch(:stage) %>.pid'
|
31
|
+
|
32
|
+
|
27
33
|
TimeoutSec=<%= fetch(:thin_wait) %>
|
28
34
|
Restart=always
|
29
35
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magic_recipes_two
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.95
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Torsten Wetzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- lib/capistrano/magic_recipes/redis.rb
|
162
162
|
- lib/capistrano/magic_recipes/secrets.rb
|
163
163
|
- lib/capistrano/magic_recipes/sidekiq.rb
|
164
|
+
- lib/capistrano/magic_recipes/sidekiq_helpers.rb
|
164
165
|
- lib/capistrano/magic_recipes/sidekiq_six.rb
|
165
166
|
- lib/capistrano/magic_recipes/thin.rb
|
166
167
|
- lib/capistrano/magic_recipes/thin_sysd.rb
|
@@ -173,7 +174,6 @@ files:
|
|
173
174
|
- lib/capistrano/tasks/lets_encrypt.rake
|
174
175
|
- lib/capistrano/tasks/logs.rake
|
175
176
|
- lib/capistrano/tasks/monit.rake
|
176
|
-
- lib/capistrano/tasks/monit_sidekiq.rake
|
177
177
|
- lib/capistrano/tasks/nginx.rake
|
178
178
|
- lib/capistrano/tasks/pwa.rake
|
179
179
|
- lib/capistrano/tasks/redirect_page.rake
|
@@ -184,17 +184,20 @@ files:
|
|
184
184
|
- lib/capistrano/tasks/thin.rake
|
185
185
|
- lib/capistrano/tasks/thin_sysd.rake
|
186
186
|
- lib/generators/capistrano/magic_recipes/templates/capistrano3_nginx_conf.erb
|
187
|
+
- lib/generators/capistrano/magic_recipes/templates/monit/alert_slack.erb
|
188
|
+
- lib/generators/capistrano/magic_recipes/templates/monit/file_checks.erb
|
187
189
|
- lib/generators/capistrano/magic_recipes/templates/monit/monitrc.erb
|
188
190
|
- lib/generators/capistrano/magic_recipes/templates/monit/nginx.erb
|
189
|
-
- lib/generators/capistrano/magic_recipes/templates/monit/nginx_conf.erb
|
190
191
|
- lib/generators/capistrano/magic_recipes/templates/monit/pm2.erb
|
191
192
|
- lib/generators/capistrano/magic_recipes/templates/monit/postgresql.erb
|
192
193
|
- lib/generators/capistrano/magic_recipes/templates/monit/pwa.erb
|
193
194
|
- lib/generators/capistrano/magic_recipes/templates/monit/redis.erb
|
194
195
|
- lib/generators/capistrano/magic_recipes/templates/monit/sidekiq.erb
|
196
|
+
- lib/generators/capistrano/magic_recipes/templates/monit/sidekiq_six.erb
|
195
197
|
- lib/generators/capistrano/magic_recipes/templates/monit/thin.erb
|
198
|
+
- lib/generators/capistrano/magic_recipes/templates/monit/thin_sysd.erb
|
196
199
|
- lib/generators/capistrano/magic_recipes/templates/monit/website.erb
|
197
|
-
- lib/generators/capistrano/magic_recipes/templates/monit/
|
200
|
+
- lib/generators/capistrano/magic_recipes/templates/monit/website_checks.erb
|
198
201
|
- lib/generators/capistrano/magic_recipes/templates/nginx.conf.erb
|
199
202
|
- lib/generators/capistrano/magic_recipes/templates/nginx/diffie_hellman.erb
|
200
203
|
- lib/generators/capistrano/magic_recipes/templates/nginx/media_cache_path.erb
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# https://github.com/seuros/capistrano-sidekiq
|
2
|
-
|
3
|
-
require 'capistrano/magic_recipes/base_helpers'
|
4
|
-
include Capistrano::MagicRecipes::BaseHelpers
|
5
|
-
|
6
|
-
namespace :load do
|
7
|
-
task :defaults do
|
8
|
-
set :sidekiq_monit_conf_dir, -> { '/etc/monit/conf.d' }
|
9
|
-
set :monit_bin, -> { '/usr/bin/monit' }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
namespace :sidekiq do
|
15
|
-
namespace :monit do
|
16
|
-
desc 'Config Sidekiq monit-service'
|
17
|
-
task :config do
|
18
|
-
on roles(fetch(:sidekiq_roles)) do |role|
|
19
|
-
@role = role
|
20
|
-
template_with_role 'sidekiq', "#{fetch(:tmp_dir)}/monit.conf", @role
|
21
|
-
sudo "mv #{fetch(:tmp_dir)}/monit.conf #{fetch(:sidekiq_monit_conf_dir)}/#{sidekiq_service_name}.conf"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
## Server specific tasks (gets overwritten by other environments!)
|
27
|
-
%w[monitor unmonitor start stop restart].each do |command|
|
28
|
-
desc "#{command} Sidekiq monit-service"
|
29
|
-
task command do
|
30
|
-
on roles(fetch(:sidekiq_roles)) do
|
31
|
-
fetch(:sidekiq_processes).times do |idx|
|
32
|
-
sudo "#{fetch(:monit_bin)} #{command} #{sidekiq_service_name(idx)}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
def sidekiq_service_name(index=nil)
|
40
|
-
fetch(:sidekiq_service_name, "#{fetch(:application)}_#{fetch(:stage)}_sidekiq_") + index.to_s
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
server {
|
2
|
-
listen 80;
|
3
|
-
server_name <%= fetch(:monit_web_domain) %>;
|
4
|
-
|
5
|
-
location ^~ /.well-known/ {
|
6
|
-
allow all;
|
7
|
-
root <%= fetch(:monit_well_known_path, "/tmp/monit/well_known") %>;
|
8
|
-
}
|
9
|
-
location / {
|
10
|
-
proxy_set_header X-Real-IP $remote_addr;
|
11
|
-
proxy_set_header Host $http_host;
|
12
|
-
proxy_pass http://127.0.0.1:<%= fetch(:monit_http_port) %>;
|
13
|
-
}
|
14
|
-
}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# Check domains on <%= fetch(:nginx_use_ssl) ? 'https' : 'http' %> for <%= fetch(:application) %> [<%= fetch(:stage) %>]
|
2
|
-
<% domain_list.uniq.each do |domain| %>
|
3
|
-
check host <%= domain %> with address <%= domain %>
|
4
|
-
if failed
|
5
|
-
<% if fetch(:nginx_use_ssl) %>
|
6
|
-
port 443
|
7
|
-
type TCPSSL
|
8
|
-
protocol https
|
9
|
-
<% else %>
|
10
|
-
port 80
|
11
|
-
protocol http
|
12
|
-
<% end %>
|
13
|
-
<% if fetch(:monit_website_check_content, false) %>
|
14
|
-
request "<%= fetch(:monit_website_check_path, '/') %>"
|
15
|
-
content = "<%= fetch(:monit_website_check_text, '<!DOCTYPE html>') %>"
|
16
|
-
<% else %>
|
17
|
-
# status = 200
|
18
|
-
<% end %>
|
19
|
-
with timeout <%= fetch(:monit_website_check_timeout, 10) %> seconds
|
20
|
-
for <%= fetch(:monit_website_check_cycles, 3) %> cycles
|
21
|
-
then alert
|
22
|
-
<% end %>
|
23
|
-
|