capistrano-unicorn-nginx 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ba9014b437c5edd7f11ec63c8837813a8e62e51
4
- data.tar.gz: 31a185073e53a2affe02dc71014cfc104643dde2
3
+ metadata.gz: 63a6067c1a22a6f89b2d5406c2f05cd2b81c5d59
4
+ data.tar.gz: 13cc40fd4612c0d29fb6109c3ba6b3cbb5c2a262
5
5
  SHA512:
6
- metadata.gz: c2b336eb13f766af1dd17053d348931640d0c802af5d35b38401484fdd9f0b53893f5f0fdf273deaf344e3bdfa2edd463ecc8f1352e2bfa1af3cadb467d25152
7
- data.tar.gz: 7b0c1270d455a5bf65e48635c6f8b92886f1f92e03e315d589a6808c8792edcfe071d3020db5f28e308faa0d6c94fd01548901906d9b66db47942e948ca83fae
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
- Set `nginx_server_name` in stage file, example `config/deploy/production.rb`:
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
- or if you don't have a domain yet:
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` # no default, required<br/>
80
- Your application's domain. You will be prompted if this option is not set.
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, "config/deploy/templates"
8
- set :nginx_server_name, -> { ask(:nginx_server_name, "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, "/run/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, "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: ") }
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 "Setup nginx configuration"
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, "-p", shared_path.join("log")
29
- template "nginx_conf.erb", "#{fetch(:tmp_dir)}/#{config_name}"
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, "-fs", "/etc/nginx/sites-available/#{config_name}", "/etc/nginx/sites-enabled/#{config_name}"
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 "Setup nginx ssl certs"
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, "root:root", "/etc/ssl/certs/#{fetch(:nginx_ssl_cert)}"
48
- sudo :chown, "root:root", "/etc/ssl/private/#{fetch(:nginx_ssl_cert_key)}"
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 "Reload nginx configuration"
52
+ desc 'Reload nginx configuration'
53
53
  task :reload do
54
54
  on roles :web do
55
- sudo "/etc/init.d/nginx reload"
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, "nginx:setup"
62
- after :started, "nginx:setup_ssl"
63
- after :publishing, "nginx:reload"
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, -> { fetch(: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 "Setup Unicorn initializer"
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
- template "unicorn_init.erb", "#{fetch(:tmp_dir)}/unicorn_init"
24
- execute :chmod, "+x", "#{fetch(:tmp_dir)}/unicorn_init"
25
- sudo :mv, "#{fetch(:tmp_dir)}/unicorn_init", "/etc/init.d/#{fetch(:unicorn_service_name)}"
26
- sudo "update-rc.d -f #{fetch(:unicorn_service_name)} defaults"
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 "Setup Unicorn app configuration"
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, "-p", shared_path.join("config")
36
- execute :mkdir, "-p", shared_path.join("log")
37
- execute :mkdir, "-p", shared_path.join("tmp/pids")
38
- template "unicorn.rb.erb", fetch(:unicorn_config)
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, "unicorn:setup_initializer"
54
- after :updated, "unicorn:setup_app_config"
55
- after :publishing, "unicorn:restart"
56
+ after :updated, 'unicorn:setup_initializer'
57
+ after :updated, 'unicorn:setup_app_config'
58
+ after :publishing, 'unicorn:restart'
56
59
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module UnicornNginx
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-unicorn-nginx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Sutic