magic_recipes_two 0.0.76 → 0.0.77
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/capistrano/magic_recipes/version.rb +1 -1
- data/lib/capistrano/tasks/monit.rake +25 -1
- data/lib/capistrano/tasks/nginx.rake +11 -0
- data/lib/generators/capistrano/magic_recipes/templates/monit/monitrc.erb +1 -1
- data/lib/generators/capistrano/magic_recipes/templates/nginx.conf.erb +5 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OWExNzJkMGUwNTBlODUyNDRjMzQ5NDRjYTBmYTg3Yzg2NWU1MGU2YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDBlMjQyOTJkOTJmMmYyOTIyMzg0NTkzNDk4YmM1YWIwOGUxZWZhZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzA0Nzc5YmYxNmMzMGM3ODE2ZDJlYTZhOWM4NmY1NTFhYzBhZjIxNGM1YmQ2
|
10
|
+
ZWY0MzdmNGFhZmYxM2YxOGM5NTRlM2NmYzk2YjZjMDA3MWY3OGY5OTA0NDA1
|
11
|
+
MmJjYTM5MGExZmNiMzUwMjFiMzc1MzU2NWI5NzcwY2I3ZjljNGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzA3NDcyNDI5ZmE4YjAzMzc0OTVmYjc5OTBlNmE1MjRkYzFkOGNkMzM5ZmU0
|
14
|
+
YmU5NzI2ZmVhZDY0ZjAzYzk1YmExMzBjYjk4MDE3MmVmMzI1NjAyY2U2MDhl
|
15
|
+
YjNhMGZkYzZlZmM4ZTA3YjkzYTJmYjdiMTFjN2QzNjE3MjZkYzU=
|
@@ -24,6 +24,7 @@ namespace :load do
|
|
24
24
|
set :monit_mail_to, -> { "foo@example.com" }
|
25
25
|
set :monit_mail_from, -> { "monit@foo.bar" }
|
26
26
|
set :monit_mail_reply_to, -> { "support@foo.bar" }
|
27
|
+
set :monit_ignore, -> { [] } # %w[action pid]
|
27
28
|
## Additional stuff for postrgres
|
28
29
|
set :postgresql_roles, -> { :db }
|
29
30
|
set :postgresql_pid, -> { "/var/run/postgresql/9.1-main.pid" }
|
@@ -34,6 +35,8 @@ namespace :load do
|
|
34
35
|
set :monit_sidekiq_timeout_sec, -> { 90 }
|
35
36
|
## Additional App helpers
|
36
37
|
set :monit_app_worker_command, -> { "cd #{ current_path } ; #{fetch(:rvm_path)}/bin/rvm #{fetch(:rvm_ruby_version)} do bundle exec MONIT_CMD" }
|
38
|
+
set :monit_app_worker_role, -> { :user } # user / bash / shell
|
39
|
+
set :monit_app_worker_prefix, -> { :rvm } # rvm / rvm1capistrano3 / env
|
37
40
|
## WebClient
|
38
41
|
set :monit_http_client, -> { true }
|
39
42
|
set :monit_http_domain, -> { false }
|
@@ -169,7 +172,28 @@ def monit_config( name, destination = nil, role = nil )
|
|
169
172
|
end
|
170
173
|
|
171
174
|
def monit_app_prefixed( cmd )
|
172
|
-
fetch(:monit_app_worker_command, "cd #{ current_path } ; bundle exec MONIT_CMD").to_s.gsub(/MONIT_CMD/, cmd)
|
175
|
+
# fetch(:monit_app_worker_command, "cd #{ current_path } ; bundle exec MONIT_CMD").to_s.gsub(/MONIT_CMD/, cmd)
|
176
|
+
|
177
|
+
case fetch(:monit_app_worker_role, :user).to_s.downcase.strip
|
178
|
+
when "sh", "shell"
|
179
|
+
komando = "/bin/sh -c 'COMMAND_PREFIX bundle exec MONIT_CMD'"
|
180
|
+
when "bash"
|
181
|
+
komando = "/bin/bash -c 'REAL_COMMAND_HERE'"
|
182
|
+
else
|
183
|
+
komando = "/bin/su - #{role.user} -c 'REAL_COMMAND_HERE'"
|
184
|
+
end
|
185
|
+
|
186
|
+
case fetch(:monit_app_worker_prefix, :env).to_s.downcase.strip
|
187
|
+
when "rvm"
|
188
|
+
komando.gsub!(/REAL_COMMAND_HERE/, "cd #{ current_path } ; #{fetch(:rvm_path)}/bin/rvm #{fetch(:rvm_ruby_version)} do bundle exec MONIT_CMD")
|
189
|
+
when "rvm1capistrano3", "rvm1capistrano", "rvm1"
|
190
|
+
komando.gsub!(/REAL_COMMAND_HERE/, "cd #{ current_path } ; #{fetch(:rvm1_auto_script_path)}/rvm-auto.sh #{fetch(:rvm1_ruby_version)} bundle exec MONIT_CMD")
|
191
|
+
else
|
192
|
+
komando.gsub!(/REAL_COMMAND_HERE/, "/usr/bin/env cd #{current_path} ; bundle exec MONIT_CMD")
|
193
|
+
end
|
194
|
+
|
195
|
+
komando.gsub(/MONIT_CMD/, cmd)
|
196
|
+
|
173
197
|
end
|
174
198
|
|
175
199
|
|
@@ -6,6 +6,7 @@ namespace :load do
|
|
6
6
|
task :defaults do
|
7
7
|
set :nginx_domains, -> { [] }
|
8
8
|
set :nginx_major_domain, -> { false }
|
9
|
+
set :nginx_domain_wildcard, -> { false }
|
9
10
|
set :nginx_remove_www, -> { true }
|
10
11
|
set :default_site, -> { false }
|
11
12
|
set :app_instances, -> { 1 }
|
@@ -147,6 +148,16 @@ namespace :nginx do
|
|
147
148
|
Array( fetch(:nginx_domains) ).map{ |d| clear_domain(d) }.uniq
|
148
149
|
end
|
149
150
|
|
151
|
+
def nginx_domains_with_www
|
152
|
+
domains = []
|
153
|
+
nginx_domains.each do |domain|
|
154
|
+
domains << domain
|
155
|
+
domains << "www.#{domain}" unless domain =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/
|
156
|
+
domains << ".#{domain}" if fetch(:nginx_domain_wildcard, false)
|
157
|
+
end
|
158
|
+
domains
|
159
|
+
end
|
160
|
+
|
150
161
|
def nginx_major_domain
|
151
162
|
fetch(:nginx_major_domain, false) ? clear_domain( fetch(:nginx_major_domain) ) : false
|
152
163
|
end
|
@@ -42,7 +42,7 @@ set mailserver <%= fetch(:monit_mail_server) %> port <%= fetch(:monit_mail_port)
|
|
42
42
|
<% end %>
|
43
43
|
with timeout 30 seconds
|
44
44
|
|
45
|
-
set alert <%= fetch(:monit_mail_to) %>
|
45
|
+
set alert <%= fetch(:monit_mail_to) %><%= Array( fetch(:monit_ignore, nil) ).count > 0 ? " but not on { #{ Array( fetch(:monit_ignore, nil) ).join(", ") } }" : "" %>
|
46
46
|
|
47
47
|
<% if fetch(:monit_http_client) %>
|
48
48
|
set httpd port <%= fetch(:monit_http_port) %>
|
@@ -17,18 +17,8 @@ upstream thin_<%= fetch(:application) %>_<%= fetch(:stage) %>_cluster {
|
|
17
17
|
<% if fetch(:nginx_major_domain) %>
|
18
18
|
server {
|
19
19
|
listen 80<%= ' default_server' if fetch(:default_site) %>;
|
20
|
-
server_name <%=
|
20
|
+
server_name <%= nginx_domains_with_www.join(joiner) %>
|
21
21
|
<%= nginx_major_domain %>;
|
22
|
-
|
23
|
-
<%#
|
24
|
-
## https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#taxing-rewrites
|
25
|
-
# return 301 https://xxxxx$request_uri;
|
26
|
-
# rewrite ^ http://xxxxx$request_uri? permanent;
|
27
|
-
# location / {
|
28
|
-
# return 301 https://xxxxx$request_uri;
|
29
|
-
# }
|
30
|
-
#%>
|
31
|
-
|
32
22
|
return 301 https://<%= nginx_major_domain %>$request_uri;
|
33
23
|
|
34
24
|
}
|
@@ -36,23 +26,12 @@ server {
|
|
36
26
|
listen 80;
|
37
27
|
server_name <%= nginx_domains.map{ |d| subdomain_regex(d) }.join(joiner) %>
|
38
28
|
<%= subdomain_regex( nginx_major_domain ) %>;
|
39
|
-
|
40
|
-
<%#
|
41
|
-
## https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#taxing-rewrites
|
42
|
-
# return 301 https://$sub.xxxxx$request_uri;
|
43
|
-
# rewrite ^ http://$sub.xxxxx$request_uri? permanent;
|
44
|
-
# location / {
|
45
|
-
# return 301 https://$sub.xxxxx$request_uri;
|
46
|
-
# }
|
47
|
-
#%>
|
48
|
-
|
49
29
|
return 301 https://$sub.<%= nginx_major_domain %>$request_uri;
|
50
|
-
|
51
30
|
}
|
52
31
|
<% else %>
|
53
32
|
server {
|
54
33
|
listen 80;
|
55
|
-
server_name <%=
|
34
|
+
server_name <%= nginx_domains_with_www.join(joiner) %>;
|
56
35
|
return 301 https://$host$request_uri;
|
57
36
|
}
|
58
37
|
server {
|
@@ -90,7 +69,7 @@ server {
|
|
90
69
|
<% else %>
|
91
70
|
server {
|
92
71
|
listen 80;
|
93
|
-
server_name <%=
|
72
|
+
server_name <%= nginx_domains_with_www.join(joiner) %>;
|
94
73
|
return 301 http://<%= nginx_major_domain %>$request_uri;
|
95
74
|
}
|
96
75
|
server {
|
@@ -115,9 +94,9 @@ server {
|
|
115
94
|
listen [::]:80<%= ' default deferred' if fetch(:default_site) %>;
|
116
95
|
<% end %>
|
117
96
|
<% if fetch(:nginx_major_domain) %>
|
118
|
-
server_name <%= "
|
97
|
+
server_name <%= "#{fetch(:nginx_domain_wildcard, false) ? "." : ""}#{fetch(:nginx_major_domain).gsub(/^\*?\./, "")}" %>;
|
119
98
|
<% else %>
|
120
|
-
server_name <%=
|
99
|
+
server_name <%= nginx_domains_with_www.join(joiner) %>;
|
121
100
|
<% end %>
|
122
101
|
|
123
102
|
<%= magic_render("nginx/remove_www") %>
|
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.77
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Torsten Wetzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|