magic_recipes_two 0.0.80 → 0.0.81
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/pwa.rb +1 -0
- data/lib/capistrano/magic_recipes/version.rb +1 -1
- data/lib/capistrano/tasks/lets_encrypt.rake +9 -0
- data/lib/capistrano/tasks/monit.rake +8 -0
- data/lib/capistrano/tasks/nginx.rake +31 -0
- data/lib/capistrano/tasks/pwa.rake +129 -0
- data/lib/generators/capistrano/magic_recipes/templates/nginx_pwa.conf.erb +84 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWNmMTE5MDFiYzhmYWNiNTY0Y2I1NjVkZTZkNTY1NmQzY2UwNzRkNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzlhOTk5Mjc1ZDY4OThkODQyYmQzODAxZmE4ZWM3NTJjNjRmMjdkYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODNkY2FkMzA0Mzg2NTQ1N2RhNmFlYmU1YjZmZjUyNzU4NzIxNTM2MDE3NzBj
|
10
|
+
OGI2MjQ2MDYxY2YwZDg1MjIxOWUzMDg1ZDEyYjU0MzJlMTBhYjVhNGFlZDBl
|
11
|
+
ZTcwMWNmZmI5NTU0ZWM0M2EzYTZiY2I4ZmRlMDYxYmRlYTE2NTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWM5MzE4ZDk2ZmI0MzM1MjRkYjdkYjA5ZDllYzUxMTQ3N2I5OTFhOTgxMWU4
|
14
|
+
OGI5MjAxNjFjYjRhZTU2ZmQ5OGE5NjYyODBjMWVjMDQ3YWMxNWFhMjg4Yzlm
|
15
|
+
NmEwNzliNzY3MDFlODMzMmZjNGRjNzFlNGE0NmJiMTc5OTgwYzU=
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path("../../tasks/pwa.rake", __FILE__)
|
@@ -89,6 +89,15 @@ namespace :lets_encrypt do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
|
93
|
+
desc "Generate LetsEncrypt certificate + expand"
|
94
|
+
task :certonly_expand do
|
95
|
+
on release_roles fetch(:lets_encrypt_roles) do
|
96
|
+
# execute "./certbot-auto certonly --webroot -w /var/www/example -d example.com -d www.example.com -w /var/www/thing -d thing.is -d m.thing.is"
|
97
|
+
execute :sudo, "#{ fetch(:lets_encrypt_path) }/certbot-auto --non-interactive --agree-tos --email #{fetch(:lets_encrypt_email)} certonly --webroot -w #{current_path}/public #{ Array(fetch(:lets_encrypt_domains)).map{ |d| "-d #{d.gsub(/^\*?\./, "")}#{ fetch(:lets_encrypt__www_domains,false) ? " -d www.#{d.gsub(/^\*?\./, "")}" : "" }" }.join(" ") } --expand"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
92
101
|
end
|
93
102
|
|
94
103
|
|
@@ -10,6 +10,7 @@ namespace :load do
|
|
10
10
|
set :monit_logfile, -> { "#{shared_path}/log/monit.log" }
|
11
11
|
set :monit_idfile, -> { '/var/lib/monit/id' }
|
12
12
|
set :monit_statefile, -> { '/var/lib/monit/state' }
|
13
|
+
set :monit_downgrade_on_deploy, -> { false }
|
13
14
|
## Status
|
14
15
|
set :monit_active, -> { true }
|
15
16
|
# set :monit_processes, -> { %w[nginx postgresql redis sidekiq thin website] }
|
@@ -87,6 +88,12 @@ namespace :monit do
|
|
87
88
|
end
|
88
89
|
# after "deploy:setup", "monit:setup"
|
89
90
|
|
91
|
+
desc 'Downgrade MONIT to 5.16 (fix action problem)'
|
92
|
+
task :downgrade_system do
|
93
|
+
on roles :db do
|
94
|
+
execute :sudo, 'apt-get -y install monit=1:5.16-2 --allow-downgrades'
|
95
|
+
end
|
96
|
+
end
|
90
97
|
|
91
98
|
%w[nginx postgresql redis sidekiq thin].each do |process|
|
92
99
|
|
@@ -199,6 +206,7 @@ end
|
|
199
206
|
|
200
207
|
namespace :deploy do
|
201
208
|
before :starting, :stop_monitoring do
|
209
|
+
invoke "monit:downgrade_system" if fetch(:monit_downgrade_on_deploy, false)
|
202
210
|
%w[sidekiq thin].each do |command|
|
203
211
|
if fetch(:monit_active) && Array(fetch(:monit_processes)).include?(command)
|
204
212
|
invoke "monit:unmonitor_#{command}"
|
@@ -122,6 +122,37 @@ namespace :nginx do
|
|
122
122
|
puts "#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#"
|
123
123
|
end
|
124
124
|
end
|
125
|
+
|
126
|
+
|
127
|
+
desc "check nginx service status"
|
128
|
+
task :check_status do
|
129
|
+
on release_roles fetch(:nginx_roles) do
|
130
|
+
output = capture(:sudo, "systemctl status nginx.service")
|
131
|
+
puts "#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#"
|
132
|
+
output.each_line do |line|
|
133
|
+
puts line
|
134
|
+
end
|
135
|
+
puts "#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
#
|
141
|
+
# Fix restart problems with nginx
|
142
|
+
# https://easyengine.io/tutorials/nginx/troubleshooting/emerg-bind-failed-98-address-already-in-use/
|
143
|
+
#
|
144
|
+
desc "fix port Problem: 0.0.0.0:80 failed (98: Address already in use)"
|
145
|
+
task :fix_port80 do
|
146
|
+
on release_roles fetch(:nginx_roles) do
|
147
|
+
execute :sudo, 'fuser -k 80/tcp'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
desc "fix ssl port Problem: 0.0.0.0:443 failed (98: Address already in use)"
|
151
|
+
task :fix_port443 do
|
152
|
+
on release_roles fetch(:nginx_roles) do
|
153
|
+
execute :sudo, 'fuser -k 443/tcp'
|
154
|
+
end
|
155
|
+
end
|
125
156
|
|
126
157
|
after 'deploy:check', nil do
|
127
158
|
on release_roles fetch(:nginx_roles) do
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'capistrano/magic_recipes/base_helpers'
|
2
|
+
include Capistrano::MagicRecipes::BaseHelpers
|
3
|
+
|
4
|
+
namespace :load do
|
5
|
+
task :defaults do
|
6
|
+
set :pwa_roles, -> { :web }
|
7
|
+
set :pwa_application, -> { "#{fetch(:application)}_mobile" }
|
8
|
+
|
9
|
+
set :pwa_root_path, -> { "#{ current_path }/dist" }
|
10
|
+
set :pwa_local_path, -> { "./dist/" }
|
11
|
+
|
12
|
+
set :pwa_domains, -> { [] }
|
13
|
+
set :pwa_major_domain, -> { false }
|
14
|
+
set :pwa_ssl_domains, -> { fetch(:pwa_major_domain,false) ? [fetch(:pwa_major_domain)] + Array(fetch(:pwa_domains)) : Array(fetch(:pwa_domains)) }
|
15
|
+
set :pwa_is_default_site, -> { false }
|
16
|
+
set :pwa_nginx_hooks, -> { false }
|
17
|
+
|
18
|
+
set :pwa_use_ssl, -> { false }
|
19
|
+
set :pwa_ssl_cert, -> { "" }
|
20
|
+
set :pwa_ssl_key, -> { "" }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace :lets_encrypt do
|
25
|
+
|
26
|
+
desc "Generate PWA LetsEncrypt certificate"
|
27
|
+
task :pwa_certonly do
|
28
|
+
on release_roles fetch(:lets_encrypt_roles) do
|
29
|
+
execute :sudo, "#{ fetch(:lets_encrypt_path) }/certbot-auto --non-interactive --agree-tos --email #{fetch(:lets_encrypt_email)} certonly --webroot -w #{ fetch(:pwa_root_path) } -d #{ fetch(:pwa_ssl_domains) }"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Generate PWA LetsEncrypt certificate + expand"
|
34
|
+
task :pwa_certonly_expand do
|
35
|
+
on release_roles fetch(:lets_encrypt_roles) do
|
36
|
+
execute :sudo, "#{ fetch(:lets_encrypt_path) }/certbot-auto --non-interactive --agree-tos --email #{fetch(:lets_encrypt_email)} certonly --webroot -w #{ fetch(:pwa_root_path) } #{ Array(fetch(:pwa_ssl_domains)).map{ |d| "-d #{d.gsub(/^\*?\./, '')}"}.join(" ") } --expand"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
namespace :pwa do
|
44
|
+
|
45
|
+
desc "upload dist folder (BETA)"
|
46
|
+
task :upload do
|
47
|
+
on roles fetch(:pwa_roles) do
|
48
|
+
local_dir = "./dist/"
|
49
|
+
remote_dir = "#{host.user}@#{host.hostname}:#{ fetch(:pwa_root_path) }"
|
50
|
+
|
51
|
+
run_locally { execute "rsync -avr --delete #{fetch(:pwa_local_path)} #{fetch(:pwa_root_path)}" }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
namespace :nginx do
|
60
|
+
|
61
|
+
task :load_pwa_vars do
|
62
|
+
set :nginx_pwa_application, -> { "pwa_#{fetch(:pwa_application)}_#{fetch(:stage)}" }
|
63
|
+
set :enabled_pwa_application, -> { File.join(fetch(:sites_enabled), "#{fetch(:pwa_application)}_#{fetch(:stage)}") }
|
64
|
+
set :available_pwa_application, -> { File.join(fetch(:sites_available), "#{fetch(:pwa_application)}_#{fetch(:stage)}") }
|
65
|
+
end
|
66
|
+
|
67
|
+
namespace :pwa_site do
|
68
|
+
|
69
|
+
desc 'Creates PWA site configuration and upload it to the available folder'
|
70
|
+
task :add => ['nginx:load_pwa_vars'] do
|
71
|
+
on release_roles fetch(:nginx_roles) do
|
72
|
+
within fetch(:sites_available) do
|
73
|
+
config_file = fetch(:pwa_nginx_template)
|
74
|
+
if config_file == :default
|
75
|
+
magic_template("nginx_pwa.conf", '/tmp/nginx_pwa.conf')
|
76
|
+
else
|
77
|
+
magic_template(config_file, '/tmp/nginx_pwa.conf')
|
78
|
+
end
|
79
|
+
execute :sudo, :mv, '/tmp/nginx_pwa.conf', fetch(:nginx_pwa_application)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
desc 'Enables PWA site creating a symbolic link into the enabled folder'
|
85
|
+
task :enable => ['nginx:load_pwa_vars'] do
|
86
|
+
on release_roles fetch(:nginx_roles) do
|
87
|
+
if test "! [ -h #{fetch(:enabled_pwa_application)} ]"
|
88
|
+
within fetch(:sites_enabled) do
|
89
|
+
execute :sudo, :ln, '-nfs', fetch(:available_pwa_application), fetch(:enabled_pwa_application)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
desc 'Disables PWA site removing the symbolic link located in the enabled folder'
|
96
|
+
task :disable => ['nginx:load_pwa_vars'] do
|
97
|
+
on release_roles fetch(:nginx_roles) do
|
98
|
+
if test "[ -f #{fetch(:enabled_pwa_application)} ]"
|
99
|
+
within fetch(:sites_enabled) do
|
100
|
+
execute :sudo, :rm, '-f', fetch(:nginx_pwa_application)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
desc 'Removes PWA site removing the configuration file from the available folder'
|
107
|
+
task :remove => ['nginx:load_pwa_vars'] do
|
108
|
+
on release_roles fetch(:nginx_roles) do
|
109
|
+
if test "[ -f #{fetch(:enabled_pwa_application)} ]"
|
110
|
+
within fetch(:sites_available) do
|
111
|
+
execute :sudo, :rm, fetch(:nginx_pwa_application)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
namespace :deploy do
|
122
|
+
before 'deploy:restart_nginx_app', :config_pwa_nginx_app do
|
123
|
+
if fetch(:pwa_nginx_hooks)
|
124
|
+
invoke "nginx:pwa_site:add"
|
125
|
+
invoke "nginx:pwa_site:enable"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Mobile - App
|
2
|
+
<% if fetch(:pwa_use_ssl) %>
|
3
|
+
<% if fetch(:pwa_major_domain, false) %>
|
4
|
+
server {
|
5
|
+
listen 80<%= ' default_server' if fetch(:pwa_is_default_site) %>;
|
6
|
+
server_name <%= Array(fetch(:pwa_domains)).join(joiner) %>;
|
7
|
+
return 301 https://<%= fetch(:pwa_major_domain) %>$request_uri;
|
8
|
+
|
9
|
+
}
|
10
|
+
<% else %>
|
11
|
+
server {
|
12
|
+
listen 80;
|
13
|
+
server_name <%= Array(fetch(:pwa_domains)).join(joiner) %>;
|
14
|
+
return 301 https://$host$request_uri;
|
15
|
+
}
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<% if fetch(:pwa_major_domain, false) %>
|
20
|
+
<% if fetch(:pwa_use_ssl) %>
|
21
|
+
# ssl-domain
|
22
|
+
server {
|
23
|
+
listen 443;
|
24
|
+
server_name <%= Array(fetch(:pwa_domains)).join(joiner) %>;
|
25
|
+
|
26
|
+
ssl on;
|
27
|
+
ssl_certificate <%= fetch(:pwa_ssl_cert) %>;
|
28
|
+
ssl_certificate_key <%= fetch(:pwa_ssl_key) %>;
|
29
|
+
|
30
|
+
return 301 https://<%= fetch(:pwa_major_domain) %>$request_uri;
|
31
|
+
}
|
32
|
+
<% else %>
|
33
|
+
server {
|
34
|
+
listen 80;
|
35
|
+
server_name <%= Array(fetch(:pwa_domains)).join(joiner) %>;
|
36
|
+
return 301 http://<%= fetch(:pwa_major_domain) %>$request_uri;
|
37
|
+
}
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
server {
|
44
|
+
<% if fetch(:nginx_use_ssl) %>
|
45
|
+
listen 443 ssl http2<%= ' default_server' if fetch(:pwa_is_default_site) %>;
|
46
|
+
#listen [::]:443 ssl http2<%= ' default_server' if fetch(:pwa_is_default_site) %>;
|
47
|
+
ssl on;
|
48
|
+
ssl_certificate <%= fetch(:pwa_ssl_cert) %>;
|
49
|
+
ssl_certificate_key <%= fetch(:pwa_ssl_key) %>;
|
50
|
+
<%= magic_render("nginx/diffie_hellman") %>
|
51
|
+
<% else %>
|
52
|
+
listen 80<%= ' default deferred' if fetch(:pwa_is_default_site) %>;
|
53
|
+
listen [::]:80<%= ' default deferred' if fetch(:pwa_is_default_site) %>;
|
54
|
+
<% end %>
|
55
|
+
|
56
|
+
<% if fetch(:nginx_major_domain) %>
|
57
|
+
server_name <%= fetch(:pwa_major_domain) %>;
|
58
|
+
<% else %>
|
59
|
+
server_name <%= Array(fetch(:pwa_domains)).join(joiner) %>;
|
60
|
+
<% end %>
|
61
|
+
|
62
|
+
client_max_body_size 4G;
|
63
|
+
keepalive_timeout 10;
|
64
|
+
|
65
|
+
root <%= fetch(:pwa_root_path) %>;
|
66
|
+
|
67
|
+
|
68
|
+
location ~ /.well-known { allow all; }
|
69
|
+
|
70
|
+
# location ^~ /css|img|js/ {
|
71
|
+
# gzip_static on;
|
72
|
+
# expires max;
|
73
|
+
# add_header Cache-Control public;
|
74
|
+
# }
|
75
|
+
|
76
|
+
# index
|
77
|
+
# index index.html;
|
78
|
+
|
79
|
+
# SPA-routing
|
80
|
+
location / {
|
81
|
+
try_files $uri $uri/ /index.html;
|
82
|
+
}
|
83
|
+
|
84
|
+
}
|
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.81
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Torsten Wetzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/capistrano/magic_recipes/logs.rb
|
156
156
|
- lib/capistrano/magic_recipes/monit.rb
|
157
157
|
- lib/capistrano/magic_recipes/nginx.rb
|
158
|
+
- lib/capistrano/magic_recipes/pwa.rb
|
158
159
|
- lib/capistrano/magic_recipes/redis.rb
|
159
160
|
- lib/capistrano/magic_recipes/secrets.rb
|
160
161
|
- lib/capistrano/magic_recipes/sidekiq.rb
|
@@ -169,6 +170,7 @@ files:
|
|
169
170
|
- lib/capistrano/tasks/monit.rake
|
170
171
|
- lib/capistrano/tasks/monit_sidekiq.rake
|
171
172
|
- lib/capistrano/tasks/nginx.rake
|
173
|
+
- lib/capistrano/tasks/pwa.rake
|
172
174
|
- lib/capistrano/tasks/redis.rake
|
173
175
|
- lib/capistrano/tasks/secrets.rake
|
174
176
|
- lib/capistrano/tasks/sidekiq.rake
|
@@ -189,6 +191,7 @@ files:
|
|
189
191
|
- lib/generators/capistrano/magic_recipes/templates/nginx/rails_cache_path.erb
|
190
192
|
- lib/generators/capistrano/magic_recipes/templates/nginx/rails_cache_server.erb
|
191
193
|
- lib/generators/capistrano/magic_recipes/templates/nginx/remove_www.erb
|
194
|
+
- lib/generators/capistrano/magic_recipes/templates/nginx_pwa.conf.erb
|
192
195
|
- lib/generators/capistrano/magic_recipes/templates/postgresql.yml.erb
|
193
196
|
- lib/generators/capistrano/magic_recipes/templates/secrets_yml.erb
|
194
197
|
- lib/generators/capistrano/magic_recipes/templates/thin_app_yml.erb
|