capistrano-nginx-unit 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 33e182a463b851db2c6a7a8b4bb56f40efa09ec1962f4f9d499835adeb52ab56
4
+ data.tar.gz: 9342e6888d8dc923cd0828ec3fc510c8bf0bcc2d3787d80667c3adee811e762d
5
+ SHA512:
6
+ metadata.gz: 1b84ef615fff5d33101fe741a4dc0197a78107163558e516e1ff49a9a6a2adccd0ad9d7257d8fa18711af0eed9e69416bd44fb5d0f743fc07e1d71fb6028403a
7
+ data.tar.gz: d493111d421d4fb17c4d7f788a5c16861c23207d220d04014f4daaa60ffb81093e8d8d5f58fca95f1ea0e6b14a1e752caf997cca6d208ba02b96edce12b62220
@@ -0,0 +1,7 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in capistrano-nginx-unit.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 murakmii
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,9 @@
1
+ # capistrano-nginx-unit
2
+
3
+ ## Installation
4
+
5
+ TODO: writing
6
+
7
+ ## Usage
8
+
9
+ TODO: writing
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "capistrano/nginx-unit/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-nginx-unit"
8
+ spec.version = Capistrano::NGINX_UNIT_VERSION
9
+ spec.authors = ["murakmii"]
10
+ spec.email = ["bonono.jp@gmail.com"]
11
+
12
+ spec.summary = "The Capistrano 3.x task to run rack application on NGINX Unit"
13
+ spec.description = "The Capistrano 3.x task to run rack application on NGINX Unit"
14
+ spec.homepage = "https://github.com/murakmii/capistrano-nginx-unit"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+
21
+ spec.add_runtime_dependency "capistrano", "~> 3.0"
22
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ require "json"
2
+
3
+ load File.expand_path('../tasks/nginx-unit.rake', __FILE__)
@@ -0,0 +1,3 @@
1
+ module Capistrano
2
+ NGINX_UNIT_VERSION = "0.1"
3
+ end
@@ -0,0 +1,70 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ set :nginx_unit_roles, -> { :app }
4
+ set :nginx_unit_control_sock, -> { "/var/run/control.unit.sock" }
5
+ set :nginx_unit_listen, -> { "*:3000" }
6
+ set :nginx_unit_app_name, -> { fetch(:application) }
7
+ set :nginx_unit_processes, -> { 1 }
8
+ set :nginx_unit_user, -> { nil }
9
+ set :nginx_unit_group, -> { nil }
10
+ set :nginx_unit_script, -> { "config.ru" }
11
+ end
12
+ end
13
+
14
+ # TODO: Start and stop NGINX Unit process
15
+ namespace :nginx_unit do
16
+ # If you want to apply new code when deployed,
17
+ # please invoke this task after deploy:published
18
+ desc "Set listener and application configuration for NGINX Unit"
19
+ task :configure do
20
+ invoke "nginx_unit:configure_app"
21
+ invoke "nginx_unit:configure_listener"
22
+ end
23
+
24
+ desc "Set listener configuration for NGINX Unit"
25
+ task :configure_listener do
26
+ on release_roles(fetch(:nginx_unit_roles)) do
27
+ listener_json = JSON.generate("application" => fetch(:application))
28
+
29
+ configure_nginx_unit("/listeners/#{fetch(:nginx_unit_listen)}", listener_json)
30
+ end
31
+ end
32
+
33
+ desc "Set application configuration for NGINX Unit"
34
+ task :configure_app do
35
+ on release_roles(fetch(:nginx_unit_roles)) do |role|
36
+ released_dir = capture(:readlink, "-f", current_path)
37
+ raise "Doesn't exist released dir: #{released_dir}" unless test("[ -d #{released_dir} ]")
38
+
39
+ app_json = JSON.generate({
40
+ type: "ruby",
41
+ processes: fetch(:nginx_unit_processes),
42
+ user: fetch(:nginx_unit_user) || role.user,
43
+ group: fetch(:nginx_unit_group) || role.user,
44
+ script: File.join(released_dir, fetch(:nginx_unit_script))
45
+ })
46
+
47
+ info "application config: #{app_json}"
48
+ configure_nginx_unit("/applications/#{fetch(:nginx_unit_app_name)}", app_json)
49
+ end
50
+ end
51
+
52
+ # Send request to NGINX Unit control socket
53
+ def configure_nginx_unit(path, json)
54
+ info "#{path} => #{json}"
55
+
56
+ res = JSON.parse(capture(:curl,
57
+ "-X PUT",
58
+ "-d '#{json}'",
59
+ "--unix-socket #{fetch(:nginx_unit_control_sock)}",
60
+ "'http://localhost/#{path}'"
61
+ ))
62
+
63
+ if res["error"]
64
+ fatal res
65
+ raise "Faild to configure"
66
+ else
67
+ info res
68
+ end
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-nginx-unit
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - murakmii
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ description: The Capistrano 3.x task to run rack application on NGINX Unit
28
+ email:
29
+ - bonono.jp@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - capistrano-nginx-unit.gemspec
40
+ - lib/capistrano-nginx-unit.rb
41
+ - lib/capistrano/nginx-unit.rb
42
+ - lib/capistrano/nginx-unit/version.rb
43
+ - lib/capistrano/tasks/nginx-unit.rake
44
+ homepage: https://github.com/murakmii/capistrano-nginx-unit
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 2.7.4
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: The Capistrano 3.x task to run rack application on NGINX Unit
68
+ test_files: []