mina-nginx 0.0.2 → 0.0.3
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 +23 -29
- data/lib/mina/nginx.rb +47 -21
- data/lib/mina/nginx/version.rb +1 -1
- data/lib/mina/templates/nginx.conf.erb +6 -7
- data/mina-nginx.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea131bbcb4d8565d2bfee03d1bab5b2b17a5c4c8
|
4
|
+
data.tar.gz: 5be0493451234e99ddee778988a994bbb4e27681
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d971e6222af56fd0e74f3af63e737b7280fde61e968c8d9f16670d5780d991a36c0905e453fd243707819a488293a9a654833add9e0d186abdc17ec406fb9b69
|
7
|
+
data.tar.gz: f778b49a2f19603cf6d73f8b7aca9fd625a480f8e85f5ffba885e2c57d860443005dcaa814ed513020fbc4e8ab1f3d2f998e562e0ef8756f155203f6024c7631
|
data/README.md
CHANGED
@@ -5,55 +5,49 @@
|
|
5
5
|
|
6
6
|
This gem provides several mina tasks:
|
7
7
|
|
8
|
-
mina nginx:
|
9
|
-
mina nginx:
|
8
|
+
mina nginx:install # Install template config to host repo for easy overrides
|
9
|
+
mina nginx:setup # Install config file to the server's shared dir + symlink
|
10
|
+
mina nginx:print # Parse & print the nginx config
|
11
|
+
|
10
12
|
mina nginx:reload # Reload Nginx
|
11
13
|
mina nginx:restart # Restart Nginx
|
12
|
-
mina nginx:setup # Setup Nginx
|
13
14
|
mina nginx:start # Start Nginx
|
14
15
|
mina nginx:status # Status Nginx
|
15
16
|
mina nginx:stop # Stop Nginx
|
16
17
|
|
17
18
|
## Installation
|
18
19
|
|
19
|
-
Add this line to your application's Gemfile
|
20
|
+
Add this line to your application's Gemfile, then `bundle install`:
|
20
21
|
|
21
22
|
gem 'mina-nginx', :require => false
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
$ bundle
|
26
|
-
|
27
|
-
Or install it yourself as:
|
28
|
-
|
29
|
-
$ gem install mina-nginx
|
30
|
-
|
31
|
-
## Usage
|
32
|
-
|
33
|
-
Add this to your `config/deploy.rb` file:
|
24
|
+
Once installed, add this to your `config/deploy.rb` file:
|
34
25
|
|
35
26
|
require 'mina/nginx'
|
36
27
|
|
37
|
-
|
28
|
+
Install the base template to your repo's `lib/mina/templates` directory:
|
29
|
+
|
30
|
+
$ bundle exec mina nginx:install
|
38
31
|
|
39
|
-
|
40
|
-
* `server_name` - your application's server_name in nginx (e.g. example.com)(optional)
|
41
|
-
* `deploy_to` - deployment path
|
32
|
+
Consider variables used by the nginx config, particularly:
|
42
33
|
|
43
|
-
|
34
|
+
* `application` - application name; defaults to 'application'
|
35
|
+
* `nginx_socket_path` - path to socket file used in nginx upstream directive
|
36
|
+
* `server_name` - application's nginx server_name (e.g. example.com); defaults to value for `domain`
|
37
|
+
* `domain` - fqdn you are deploying to
|
38
|
+
* `deploy_to` - deployment path
|
39
|
+
* `current_path` - current revision path
|
44
40
|
|
45
|
-
|
46
|
-
$ mina nginx:setup
|
47
|
-
$ mina nginx:link
|
48
|
-
```
|
41
|
+
Edit installed template as required.
|
49
42
|
|
50
|
-
|
43
|
+
## Recommended Usage
|
51
44
|
|
52
|
-
|
45
|
+
1. Follow install steps above; and
|
46
|
+
2. Invoke `nginx:setup` in your main `setup` task
|
47
|
+
3. Run `nginx:setup` (or base `setup`) to install config changes
|
53
48
|
|
54
|
-
|
55
|
-
|
56
|
-
```
|
49
|
+
n.b. if the config template has not been installed locally, `mina-nginx` will
|
50
|
+
fall back to the default template gracefully.
|
57
51
|
|
58
52
|
## Contributing
|
59
53
|
|
data/lib/mina/nginx.rb
CHANGED
@@ -1,31 +1,48 @@
|
|
1
1
|
require 'mina/nginx/version'
|
2
2
|
|
3
3
|
namespace :nginx do
|
4
|
-
|
5
|
-
set :nginx_group, 'www-data'
|
6
|
-
set :nginx_path, '/etc/nginx'
|
7
|
-
set :nginx_config, -> { "#{fetch(:shared_path)}/config/nginx.conf" }
|
8
|
-
set :nginx_config_e, -> { "#{fetch(:nginx_path)}/sites-enabled/#{application}.conf" }
|
4
|
+
application = fetch :application, 'application'
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
set :nginx_user, 'www-data'
|
7
|
+
set :nginx_group, 'www-data'
|
8
|
+
set :nginx_path, '/etc/nginx'
|
9
|
+
set :nginx_config, -> { "#{fetch(:shared_path)}/config/nginx.conf" }
|
10
|
+
set :nginx_config_e, -> { "#{fetch(:nginx_path)}/sites-enabled/#{application}.conf" }
|
11
|
+
set :nginx_socket_path, -> { "#{fetch(:shared_path)}/tmp/puma.sock" }
|
12
|
+
|
13
|
+
desc 'Install Nginx config to repo'
|
14
|
+
task :install => :environment do
|
15
|
+
run :local do
|
16
|
+
installed_path = path_for_template
|
17
|
+
|
18
|
+
if File.exist? installed_path
|
19
|
+
error! %(file exists; please rm to continue: #{installed_path})
|
20
|
+
else
|
21
|
+
command %(mkdir -p config/deploy/templates)
|
22
|
+
command %(cp #{nginx_template} #{installed_path})
|
23
|
+
end
|
24
|
+
end
|
15
25
|
end
|
16
26
|
|
17
|
-
desc '
|
18
|
-
task :
|
19
|
-
|
20
|
-
|
27
|
+
desc 'Print nginx config in local terminal'
|
28
|
+
task :print => :environment do
|
29
|
+
run :local do
|
30
|
+
command %(echo '#{erb nginx_template}')
|
31
|
+
end
|
21
32
|
end
|
22
33
|
|
23
|
-
desc '
|
24
|
-
task :
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
comment %(
|
34
|
+
desc 'Setup Nginx on server'
|
35
|
+
task :setup => :environment do
|
36
|
+
nginx_config = fetch :nginx_config
|
37
|
+
nginx_enabled_config = fetch :nginx_config_e
|
38
|
+
|
39
|
+
comment %(Installing nginx config file to #{nginx_config})
|
40
|
+
command %(echo '#{erb nginx_template}' > #{nginx_config})
|
41
|
+
|
42
|
+
comment %(Symlinking nginx config file to #{nginx_enabled_config})
|
43
|
+
command %(sudo ln -nfs #{nginx_config} #{nginx_enabled_config})
|
44
|
+
|
45
|
+
invoke :'nginx:restart'
|
29
46
|
end
|
30
47
|
|
31
48
|
%w(stop start restart reload status).each do |action|
|
@@ -39,6 +56,15 @@ namespace :nginx do
|
|
39
56
|
private
|
40
57
|
|
41
58
|
def nginx_template
|
42
|
-
|
59
|
+
installed_path = path_for_template
|
60
|
+
template_path = path_for_template installed: false
|
61
|
+
|
62
|
+
File.exist?(installed_path) ? installed_path : template_path
|
63
|
+
end
|
64
|
+
|
65
|
+
def path_for_template installed: true
|
66
|
+
installed ?
|
67
|
+
File.expand_path('./config/deploy/templates/nginx.conf.erb') :
|
68
|
+
File.expand_path('../templates/nginx.conf.erb', __FILE__)
|
43
69
|
end
|
44
70
|
end
|
data/lib/mina/nginx/version.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
+
<% application = fetch :application, 'application' %>
|
2
|
+
<% socket_path = fetch :nginx_socket_path, '/path/to/web/socket' %>
|
3
|
+
|
1
4
|
upstream <%= application %> {
|
2
|
-
|
3
|
-
# server 127.0.0.1:8080 max_fails=3 fail_timeout=30s;
|
4
|
-
# server unix:///path/to/web_socket.sock;
|
5
|
-
#
|
6
|
-
server unix:///PATH/TO/WEB_SOCKET fail_timeout=0;
|
5
|
+
server unix://<%= socket_path %> fail_timeout=0;
|
7
6
|
}
|
8
7
|
|
9
8
|
server {
|
10
9
|
listen 80 default deferred;
|
11
|
-
|
12
|
-
root <%= deploy_to
|
10
|
+
server_name <%= fetch :server_name, fetch(:domain) %>
|
11
|
+
root <%= "#{fetch :deploy_to}/#{fetch :current_path}/public" %>;
|
13
12
|
|
14
13
|
location ^~ /assets/ {
|
15
14
|
gzip_static on;
|
data/mina-nginx.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'mina/nginx/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'mina-nginx'
|
8
8
|
spec.version = Mina::Nginx::VERSION
|
9
|
-
spec.authors = ['hbin']
|
9
|
+
spec.authors = ['hbin', 'anulman']
|
10
10
|
spec.email = ['huangbin88@foxmail.com']
|
11
11
|
spec.summary = %(Mina tasks for handle with Nginx.)
|
12
12
|
spec.description = %(Configuration and managements Mina tasks for Nginx.)
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mina-nginx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hbin
|
8
|
+
- anulman
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: mina
|
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
89
|
version: '0'
|
89
90
|
requirements: []
|
90
91
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
92
|
+
rubygems_version: 2.6.8
|
92
93
|
signing_key:
|
93
94
|
specification_version: 4
|
94
95
|
summary: Mina tasks for handle with Nginx.
|