mina-nginx 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f1524f73b74a9fcd393dde060743a323b917754f
4
+ data.tar.gz: 3063f7a458deb75d6bab43a07699592fdba635c3
5
+ SHA512:
6
+ metadata.gz: 41b1f6e05ab72567afa57a0cc8c9fbf8da51da0e5a54d28601feed109a3e8bf869bb0a1bf6841e9e35d1ae2f57a6ce1bc27cabc46efc5aa98f5b692e496120be
7
+ data.tar.gz: 4e03f71ee33dc85da1471ea1f868ccd2ada2a87159f011de3d2c9f918c296548087a32002d06f6004c642ae136aaa739f59dfcb687bd42f7fcd0a046f7e95771
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ TAGS
19
+ tags
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mina-nginx.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 hbin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # Mina Nginx
2
+
3
+ [Mina](https://github.com/nadarei/mina) tasks for handle with
4
+ [Nginx](http://nginx.com/).
5
+
6
+ This gem provides several mina tasks:
7
+
8
+ mina nginx:link # Symlinking nginx config file
9
+ mina nginx:parse # Parse nginx configuration file and upload it to the server
10
+ mina nginx:reload # Reload Nginx
11
+ mina nginx:restart # Restart Nginx
12
+ mina nginx:setup # Setup Nginx
13
+ mina nginx:start # Start Nginx
14
+ mina nginx:status # Status Nginx
15
+ mina nginx:stop # Stop Nginx
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ gem 'mina-nginx', :require => false
22
+
23
+ And then execute:
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:
34
+
35
+ require 'mina/nginx'
36
+
37
+ Make sure the following settings are setted in your `config/deploy.rb`:
38
+
39
+ * `application` - application name
40
+ * `server_name` - your application's server_name in nginx (e.g. example.com)(optional)
41
+ * `deploy_to` - deployment path
42
+
43
+ Launch new tasks:
44
+
45
+ ```
46
+ $ mina nginx:setup
47
+ $ mina nginx:link
48
+ ```
49
+
50
+ Be sure to edit `shared/config/nginx.conf` on your server. Or you can parse an sample
51
+ configuration file by `mina nginx:parse` on your server.
52
+
53
+ Then:
54
+
55
+ ```
56
+ $ mina nginx:reload
57
+ ```
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it ( http://github.com/<my-github-username>/mina-nginx/fork )
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/mina/nginx.rb ADDED
@@ -0,0 +1,44 @@
1
+ require "mina/nginx/version"
2
+
3
+ namespace :nginx do
4
+ set_default :nginx_user, "www-data"
5
+ set_default :nginx_group, "www-data"
6
+ set_default :nginx_path, "/etc/nginx"
7
+ set_default :nginx_config, -> { "#{deploy_to}/#{shared_path}/config/nginx.conf" }
8
+ set_default :nginx_config_e, -> { "#{nginx_path}/sites-enabled/#{application}.conf" }
9
+
10
+ desc 'Setup Nginx'
11
+ task :setup => :environment do
12
+ queue %(echo "-----> Setup the nginx")
13
+ queue! %(touch #{nginx_config})
14
+ queue %(echo "-----> Be sure to edit 'shared/config/nginx.conf'.")
15
+ end
16
+
17
+ desc 'Symlinking nginx config file'
18
+ task :link => :environment do
19
+ queue %(echo "-----> Symlinking nginx config file")
20
+ queue! %(sudo ln -nfs "#{nginx_config}" "#{nginx_config_e}")
21
+ end
22
+
23
+ desc 'Parse nginx configuration file and upload it to the server.'
24
+ task :parse => :environment do
25
+ content = erb(nginx_template)
26
+ queue %(echo '#{content}' > #{nginx_config})
27
+ queue %(cat #{nginx_config})
28
+ queue %(echo "-----> Be sure to edit 'shared/config/nginx.conf'.")
29
+ end
30
+
31
+ %w(stop start restart reload status).each do |action|
32
+ desc "#{action.capitalize} Nginx"
33
+ task action.to_sym => :environment do
34
+ queue %(echo "-----> #{action.capitalize} Nginx")
35
+ queue! "sudo service nginx #{action}"
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def nginx_template
42
+ File.expand_path('../templates/nginx.conf.erb', __FILE__)
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ module Mina
2
+ module Nginx
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ upstream <%= application %> {
2
+ # server www.example.com weight=5;
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;
7
+ }
8
+
9
+ server {
10
+ listen 80 default deferred;
11
+ <%= server_name.to_s.empty? ? "# server_name example.com" : "server_name #{server_name}" %>;
12
+ root <%= deploy_to %>/<%= current_path %>/public;
13
+
14
+ location ^~ /assets/ {
15
+ gzip_static on;
16
+ expires max;
17
+ add_header Cache-Control public;
18
+ }
19
+
20
+ try_files $uri/index.html $uri @<%= application %>;
21
+ location @<%= application %> {
22
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
23
+ proxy_set_header Host $http_host;
24
+ proxy_redirect off;
25
+ proxy_pass http://<%= application %>;
26
+ }
27
+
28
+ error_page 500 502 503 504 /500.html;
29
+ client_max_body_size 4G;
30
+ keepalive_timeout 10;
31
+ }
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mina/nginx/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mina-nginx"
8
+ spec.version = Mina::Nginx::VERSION
9
+ spec.authors = ["hbin"]
10
+ spec.email = ["huangbin88@foxmail.com"]
11
+ spec.summary = %q{Mina tasks for handle with Nginx.}
12
+ spec.description = %q{Configuration and managements Mina tasks for Nginx.}
13
+ spec.homepage = "https://github.com/hbin/mina-nginx.git"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "mina", "~> 0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mina-nginx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - hbin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mina
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Configuration and managements Mina tasks for Nginx.
56
+ email:
57
+ - huangbin88@foxmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/mina/nginx.rb
68
+ - lib/mina/nginx/version.rb
69
+ - lib/mina/templates/nginx.conf.erb
70
+ - mina-nginx.gemspec
71
+ homepage: https://github.com/hbin/mina-nginx.git
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.2.0
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Mina tasks for handle with Nginx.
95
+ test_files: []
96
+ has_rdoc: