capistrano-nginx-unit 0.2 → 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/.editorconfig +10 -0
- data/README.md +8 -5
- data/lib/capistrano/nginx-unit/version.rb +1 -1
- data/lib/capistrano/tasks/nginx-unit.rake +40 -27
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46570db097e14918f9d04863542c5832a9fbdb72cbd8fb974296a534608f9c69
|
4
|
+
data.tar.gz: dd0b9a3ab22b37c83598322d0842af3e46e0189f9dc508fc45065a5e73cc9191
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84a684b6ee4c2576d52bafb6fd19501ea8434b9057a7390c3710744329ddd0e7643969261f083cbc819192ce707a50f9219da84b2311b87e6e1521e0f9800ca9
|
7
|
+
data.tar.gz: 168c9932f4b17f74d5bf8ece2859595596026ce960afdb4e8c01d141aca9dd445e2cb4700b4c1dc0672b2e64f76111674debbd9090e6d8dd64df512ac386cf27
|
data/.editorconfig
ADDED
data/README.md
CHANGED
@@ -18,9 +18,12 @@ require "capistrano/nginx-unit"
|
|
18
18
|
Defined following tasks.
|
19
19
|
|
20
20
|
```
|
21
|
-
cap nginx_unit:
|
22
|
-
cap nginx_unit:
|
23
|
-
cap nginx_unit:
|
21
|
+
cap nginx_unit:attach # Attach listener and application configuration to NGINX Unit
|
22
|
+
cap nginx_unit:attach_app # Attach application configuration to NGINX Unit
|
23
|
+
cap nginx_unit:attach_listener # Attach listener configuration to NGINX Unit
|
24
|
+
cap nginx_unit:detach # Detach listener and application configuration from NGINX Unit
|
25
|
+
cap nginx_unit:detach_app # Detach application configuration from NGINX Unit
|
26
|
+
cap nginx_unit:detach_listener # Detach listener configuration from NGINX Unit
|
24
27
|
cap nginx_unit:start # Start NGINX Unit process
|
25
28
|
```
|
26
29
|
|
@@ -39,9 +42,9 @@ set :nginx_unit_group, -> { nil }
|
|
39
42
|
set :nginx_unit_script, -> { "config.ru" }
|
40
43
|
```
|
41
44
|
|
42
|
-
If you want to apply new code when deployed, please invoke `nginx_unit:
|
45
|
+
If you want to apply new code when deployed, please invoke `nginx_unit:attach` task after `deploy:published`.
|
43
46
|
|
44
47
|
```rb
|
45
48
|
# deploy.rb
|
46
|
-
after "deploy:published", "nginx_unit:
|
49
|
+
after "deploy:published", "nginx_unit:attach"
|
47
50
|
```
|
@@ -22,8 +22,8 @@ namespace :nginx_unit do
|
|
22
22
|
if test("[ -e #{pid_file} ] && kill -0 `cat #{pid_file}`")
|
23
23
|
info "NGINX Unit is already started"
|
24
24
|
else
|
25
|
-
execute :sudo, :unitd,
|
26
|
-
"--pid #{pid_file}",
|
25
|
+
execute :sudo, :unitd,
|
26
|
+
"--pid #{pid_file}",
|
27
27
|
"--control unix:#{fetch(:nginx_unit_control_sock)}",
|
28
28
|
fetch(:nginx_unit_options)
|
29
29
|
end
|
@@ -32,24 +32,23 @@ namespace :nginx_unit do
|
|
32
32
|
|
33
33
|
# If you want to apply new code when deployed,
|
34
34
|
# please invoke this task after deploy:published
|
35
|
-
desc "
|
36
|
-
task :
|
35
|
+
desc "Attach listener and application configuration to NGINX Unit"
|
36
|
+
task :attach do
|
37
37
|
invoke "nginx_unit:start"
|
38
|
-
invoke "nginx_unit:
|
39
|
-
invoke "nginx_unit:
|
38
|
+
invoke "nginx_unit:attach_app"
|
39
|
+
invoke "nginx_unit:attach_listener"
|
40
40
|
end
|
41
41
|
|
42
|
-
desc "
|
43
|
-
task :
|
42
|
+
desc "Attach listener configuration to NGINX Unit"
|
43
|
+
task :attach_listener do
|
44
44
|
on release_roles(fetch(:nginx_unit_roles)) do
|
45
45
|
listener_json = JSON.generate("application" => fetch(:application))
|
46
|
-
|
47
|
-
configure_nginx_unit("/listeners/#{fetch(:nginx_unit_listen)}", listener_json)
|
46
|
+
control_nginx_unit(:put, path: "/listeners/#{fetch(:nginx_unit_listen)}", json: listener_json)
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
desc "
|
52
|
-
task :
|
50
|
+
desc "Attach application configuration to NGINX Unit"
|
51
|
+
task :attach_app do
|
53
52
|
on release_roles(fetch(:nginx_unit_roles)) do |role|
|
54
53
|
released_dir = capture(:readlink, "-f", current_path)
|
55
54
|
raise "Doesn't exist released dir: #{released_dir}" unless test("[ -d #{released_dir} ]")
|
@@ -62,27 +61,41 @@ namespace :nginx_unit do
|
|
62
61
|
script: File.join(released_dir, fetch(:nginx_unit_script))
|
63
62
|
})
|
64
63
|
|
65
|
-
|
66
|
-
configure_nginx_unit("/applications/#{fetch(:nginx_unit_app_name)}", app_json)
|
64
|
+
control_nginx_unit(:put, path: "/applications/#{fetch(:nginx_unit_app_name)}", json: app_json)
|
67
65
|
end
|
68
66
|
end
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
desc "Detach listener and application configuration from NGINX Unit"
|
69
|
+
task :detach do
|
70
|
+
invoke "nginx_unit:detach_listener"
|
71
|
+
invoke "nginx_unit:detach_app"
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "Detach listener configuration from NGINX Unit"
|
75
|
+
task :detach_listener do
|
76
|
+
on release_roles(fetch(:nginx_unit_roles)) do
|
77
|
+
control_nginx_unit(:delete, path: "/listeners/#{fetch(:nginx_unit_listen)}")
|
78
|
+
end
|
79
|
+
end
|
73
80
|
|
74
|
-
|
75
|
-
|
76
|
-
|
81
|
+
desc "Detach application configuration from NGINX Unit"
|
82
|
+
task :detach_app do
|
83
|
+
on release_roles(fetch(:nginx_unit_roles)) do
|
84
|
+
control_nginx_unit(:delete, path: "/applications/#{fetch(:nginx_unit_app_name)}")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Send request to NGINX Unit control socket
|
89
|
+
def control_nginx_unit(method, path: "", json: nil)
|
90
|
+
args = [
|
91
|
+
"-fs",
|
92
|
+
"-X #{method.to_s.upcase}",
|
77
93
|
"--unix-socket #{fetch(:nginx_unit_control_sock)}",
|
78
94
|
"'http://localhost/#{path}'"
|
79
|
-
|
95
|
+
]
|
80
96
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
else
|
85
|
-
info res
|
86
|
-
end
|
97
|
+
args << "-d '#{json}'" if json
|
98
|
+
|
99
|
+
execute :curl, *args
|
87
100
|
end
|
88
101
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-nginx-unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- murakmii
|
@@ -31,6 +31,7 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
+
- ".editorconfig"
|
34
35
|
- ".gitignore"
|
35
36
|
- Gemfile
|
36
37
|
- LICENSE.txt
|