capistrano-unicorn-nginx 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -13
- data/lib/capistrano/tasks/nginx.rake +17 -17
- data/lib/capistrano/tasks/unicorn.rake +17 -14
- data/lib/capistrano/unicorn_nginx/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63a6067c1a22a6f89b2d5406c2f05cd2b81c5d59
|
|
4
|
+
data.tar.gz: 13cc40fd4612c0d29fb6109c3ba6b3cbb5c2a262
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66a25720f758524dccb47ba0c376ee3fd729cf6c991c2512e2d32f9fcf91907b66c9c895ddfa5ca321913ea7a80b6f6d287b4c54a9a72c783311ac16ee5c58a0
|
|
7
|
+
data.tar.gz: 45fe6bff72128006fa5e2bd2fb96433f572b40e2e4b3190288d4064146e0c533b3faae406115c1c6a1fa78be49ecdd277ad0e59a2bde4e35024efd1779303568
|
data/README.md
CHANGED
|
@@ -43,14 +43,13 @@ Add this line to `Capfile`
|
|
|
43
43
|
|
|
44
44
|
require 'capistrano/unicorn-nginx'
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
If you already have a domain for your app, set `nginx_server_name` in stage
|
|
47
|
+
file, example `config/deploy/production.rb`:
|
|
47
48
|
|
|
48
|
-
set :user, 'deployer' # user doing the deploy
|
|
49
49
|
set :nginx_server_name, 'mydomain.com'
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
set :nginx_server_name, '<server_ip>'
|
|
51
|
+
If you don't have a domain yet, you do not have to do anything
|
|
52
|
+
(`nginx_server_name` will use the default value - server IP).
|
|
54
53
|
|
|
55
54
|
And you're all set!
|
|
56
55
|
|
|
@@ -76,10 +75,8 @@ In order to override the default, put the option in the stage file, for example:
|
|
|
76
75
|
|
|
77
76
|
Defaults are listed near option name in the first line.
|
|
78
77
|
|
|
79
|
-
- `set :nginx_server_name` #
|
|
80
|
-
Your application's domain.
|
|
81
|
-
If you do not have a domain, you can put server IP - in this case you can
|
|
82
|
-
deploy only one application on the server.
|
|
78
|
+
- `set :nginx_server_name` # defaults to <server_IP><br/>
|
|
79
|
+
Your application's domain. The default is your server's IP address.
|
|
83
80
|
|
|
84
81
|
- `set :nginx_pid, "/run/nginx.pid"`<br/>
|
|
85
82
|
Path for nginx process pid file.
|
|
@@ -127,10 +124,6 @@ Path for unicorn config file.
|
|
|
127
124
|
- `set :unicorn_log, shared_path.join("log/unicorn.log")`<br/>
|
|
128
125
|
Unicorn log path.
|
|
129
126
|
|
|
130
|
-
- `set :user` # no default, required<br/>
|
|
131
|
-
User name to run unicorn. This should be the name of the user doing the deploy,
|
|
132
|
-
example: `set :user, 'deploy'`
|
|
133
|
-
|
|
134
127
|
- `set :unicorn_workers, 2`<br/>
|
|
135
128
|
Number of unicorn workers.
|
|
136
129
|
|
|
@@ -4,35 +4,35 @@ include Capistrano::UnicornNginx::Helpers
|
|
|
4
4
|
|
|
5
5
|
namespace :load do
|
|
6
6
|
task :defaults do
|
|
7
|
-
set :templates_path,
|
|
8
|
-
set :nginx_server_name, -> {
|
|
7
|
+
set :templates_path, 'config/deploy/templates'
|
|
8
|
+
set :nginx_server_name, -> { host.to_s }
|
|
9
9
|
set :nginx_config_name, -> { "#{fetch(:application)}_#{fetch(:stage)}" }
|
|
10
|
-
set :nginx_pid,
|
|
10
|
+
set :nginx_pid, '/run/nginx.pid'
|
|
11
11
|
# ssl options
|
|
12
12
|
set :nginx_use_ssl, false
|
|
13
13
|
set :nginx_ssl_cert, -> { "#{fetch(:nginx_server_name)}.crt" }
|
|
14
14
|
set :nginx_ssl_cert_key, -> { "#{fetch(:nginx_server_name)}.key" }
|
|
15
15
|
set :nginx_upload_local_cert, true
|
|
16
|
-
set :nginx_ssl_cert_local_path, -> { ask(:nginx_ssl_cert_local_path,
|
|
17
|
-
set :nginx_ssl_cert_key_local_path, -> { ask(:nginx_ssl_cert_key_local_path,
|
|
16
|
+
set :nginx_ssl_cert_local_path, -> { ask(:nginx_ssl_cert_local_path, 'Local path to ssl certificate: ') }
|
|
17
|
+
set :nginx_ssl_cert_key_local_path, -> { ask(:nginx_ssl_cert_key_local_path, 'Local path to ssl certificate key: ') }
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
namespace :nginx do
|
|
22
|
-
desc
|
|
22
|
+
desc 'Setup nginx configuration'
|
|
23
23
|
task :setup do
|
|
24
24
|
on roles :web do
|
|
25
25
|
config_name = fetch(:nginx_config_name)
|
|
26
26
|
next if file_exists? "/etc/nginx/sites-available/#{config_name}"
|
|
27
27
|
|
|
28
|
-
execute :mkdir,
|
|
29
|
-
template
|
|
28
|
+
execute :mkdir, '-p', shared_path.join('log')
|
|
29
|
+
template 'nginx_conf.erb', "#{fetch(:tmp_dir)}/#{config_name}"
|
|
30
30
|
sudo :mv, "#{fetch(:tmp_dir)}/#{config_name}", "/etc/nginx/sites-available/#{config_name}"
|
|
31
|
-
sudo :ln,
|
|
31
|
+
sudo :ln, '-fs', "/etc/nginx/sites-available/#{config_name}", "/etc/nginx/sites-enabled/#{config_name}"
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
desc
|
|
35
|
+
desc 'Setup nginx ssl certs'
|
|
36
36
|
task :setup_ssl do
|
|
37
37
|
on roles :web do
|
|
38
38
|
next unless fetch(:nginx_use_ssl)
|
|
@@ -44,21 +44,21 @@ namespace :nginx do
|
|
|
44
44
|
sudo :mv, "#{fetch(:tmp_dir)}/#{fetch(:nginx_ssl_cert)}", "/etc/ssl/certs/#{fetch(:nginx_ssl_cert)}"
|
|
45
45
|
sudo :mv, "#{fetch(:tmp_dir)}/#{fetch(:nginx_ssl_cert_key)}", "/etc/ssl/private/#{fetch(:nginx_ssl_cert_key)}"
|
|
46
46
|
end
|
|
47
|
-
sudo :chown,
|
|
48
|
-
sudo :chown,
|
|
47
|
+
sudo :chown, 'root:root', "/etc/ssl/certs/#{fetch(:nginx_ssl_cert)}"
|
|
48
|
+
sudo :chown, 'root:root', "/etc/ssl/private/#{fetch(:nginx_ssl_cert_key)}"
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
desc
|
|
52
|
+
desc 'Reload nginx configuration'
|
|
53
53
|
task :reload do
|
|
54
54
|
on roles :web do
|
|
55
|
-
sudo
|
|
55
|
+
sudo '/etc/init.d/nginx reload'
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
namespace :deploy do
|
|
61
|
-
after :started,
|
|
62
|
-
after :started,
|
|
63
|
-
after :publishing,
|
|
61
|
+
after :started, 'nginx:setup'
|
|
62
|
+
after :started, 'nginx:setup_ssl'
|
|
63
|
+
after :publishing, 'nginx:reload'
|
|
64
64
|
end
|
|
@@ -9,33 +9,36 @@ namespace :load do
|
|
|
9
9
|
set :unicorn_pid, -> { shared_path.join("tmp/pids/unicorn.pid") }
|
|
10
10
|
set :unicorn_config, -> { shared_path.join("config/unicorn.rb") }
|
|
11
11
|
set :unicorn_log, -> { shared_path.join("log/unicorn.log") }
|
|
12
|
-
set :unicorn_user,
|
|
12
|
+
set :unicorn_user, nil # user is set by executing `id -un` on the server
|
|
13
13
|
set :unicorn_workers, 2
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
namespace :unicorn do
|
|
18
|
-
desc
|
|
18
|
+
desc 'Setup Unicorn initializer'
|
|
19
19
|
task :setup_initializer do
|
|
20
20
|
on roles :app do
|
|
21
21
|
next if file_exists? "/etc/init.d/#{fetch(:unicorn_service_name)}"
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
set :unicorn_user, capture(:id, '-un') unless fetch(:unicorn_user)
|
|
24
|
+
init_tmp = "#{fetch(:tmp_dir)}/unicorn_init"
|
|
25
|
+
|
|
26
|
+
template 'unicorn_init.erb', init_tmp
|
|
27
|
+
execute :chmod, "+x", init_tmp
|
|
28
|
+
sudo :mv, init_tmp, "/etc/init.d/#{fetch(:unicorn_service_name)}"
|
|
29
|
+
sudo 'update-rc.d', '-f', fetch(:unicorn_service_name), 'defaults'
|
|
27
30
|
end
|
|
28
31
|
end
|
|
29
32
|
|
|
30
|
-
desc
|
|
33
|
+
desc 'Setup Unicorn app configuration'
|
|
31
34
|
task :setup_app_config do
|
|
32
35
|
on roles :app do
|
|
33
36
|
next if file_exists? fetch(:unicorn_config)
|
|
34
37
|
|
|
35
|
-
execute :mkdir,
|
|
36
|
-
execute :mkdir,
|
|
37
|
-
execute :mkdir,
|
|
38
|
-
template
|
|
38
|
+
execute :mkdir, '-p', shared_path.join('config')
|
|
39
|
+
execute :mkdir, '-p', shared_path.join('log')
|
|
40
|
+
execute :mkdir, '-p', shared_path.join('tmp/pids')
|
|
41
|
+
template 'unicorn.rb.erb', fetch(:unicorn_config)
|
|
39
42
|
end
|
|
40
43
|
end
|
|
41
44
|
|
|
@@ -50,7 +53,7 @@ namespace :unicorn do
|
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
namespace :deploy do
|
|
53
|
-
after :updated,
|
|
54
|
-
after :updated,
|
|
55
|
-
after :publishing,
|
|
56
|
+
after :updated, 'unicorn:setup_initializer'
|
|
57
|
+
after :updated, 'unicorn:setup_app_config'
|
|
58
|
+
after :publishing, 'unicorn:restart'
|
|
56
59
|
end
|