capistrano-nginx-unit 0.3 → 0.4
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/.gitignore +1 -0
- data/README.md +11 -8
- data/lib/capistrano/nginx-unit/version.rb +1 -1
- data/lib/capistrano/tasks/nginx-unit.rake +36 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 546d8dfde3f9be1b32a84ccb0be6929d9493a1e89a7ce6587552176f71410975
|
4
|
+
data.tar.gz: 83f15ae81573d3b60cd0cce3743f02b230491399106baf654fa35d1948812b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1368025a4451ae352f1870459a991f4136ee9f2b1a6514552bea9e8f943cc69dc90391c756124bf57ede91a5f3371c5d2a213c60017d8bd706f647db18586b38
|
7
|
+
data.tar.gz: 939182f24578fb26d1bdd28bc0c3a4a6418a27a24e3d38bf697f447ba9bf29f34a80177317cde016262c1190fd8ed136ceb52537065da3b988dc2f7b28ea5119
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -25,9 +25,19 @@ cap nginx_unit:detach # Detach listener and application configurati
|
|
25
25
|
cap nginx_unit:detach_app # Detach application configuration from NGINX Unit
|
26
26
|
cap nginx_unit:detach_listener # Detach listener configuration from NGINX Unit
|
27
27
|
cap nginx_unit:start # Start NGINX Unit process
|
28
|
+
cap nginx_unit:stop # Stop NGINX Unit process
|
28
29
|
```
|
29
30
|
|
30
|
-
|
31
|
+
`nginx_unit:attach` is main task.
|
32
|
+
The task [sends HTTP request to configure NGINX Unit](http://unit.nginx.org/configuration/) on server.
|
33
|
+
If you want to apply new code when deployed, please invoke `nginx_unit:attach` task after `deploy:published`.
|
34
|
+
|
35
|
+
```rb
|
36
|
+
# deploy.rb
|
37
|
+
after "deploy:published", "nginx_unit:attach"
|
38
|
+
```
|
39
|
+
|
40
|
+
## Options
|
31
41
|
|
32
42
|
```rb
|
33
43
|
set :nginx_unit_roles, -> { :app }
|
@@ -41,10 +51,3 @@ set :nginx_unit_user, -> { nil }
|
|
41
51
|
set :nginx_unit_group, -> { nil }
|
42
52
|
set :nginx_unit_script, -> { "config.ru" }
|
43
53
|
```
|
44
|
-
|
45
|
-
If you want to apply new code when deployed, please invoke `nginx_unit:attach` task after `deploy:published`.
|
46
|
-
|
47
|
-
```rb
|
48
|
-
# deploy.rb
|
49
|
-
after "deploy:published", "nginx_unit:attach"
|
50
|
-
```
|
@@ -13,7 +13,6 @@ namespace :load do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
# TODO: Stop NGINX Unit process
|
17
16
|
namespace :nginx_unit do
|
18
17
|
desc "Start NGINX Unit process"
|
19
18
|
task :start do
|
@@ -30,6 +29,19 @@ namespace :nginx_unit do
|
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
32
|
+
# NOTE: Should we detach listener and application before killing?
|
33
|
+
desc "Stop NGINX Unit process"
|
34
|
+
task :stop do
|
35
|
+
on release_roles(fetch(:nginx_unit_roles)) do
|
36
|
+
pid_file = fetch(:nginx_unit_pid)
|
37
|
+
if test("[ -e #{pid_file} ] && kill -0 `cat #{pid_file}`")
|
38
|
+
execute :sudo, :kill, "-s QUIT `cat #{pid_file}`"
|
39
|
+
else
|
40
|
+
info "NGINX Unit is already stopped"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
33
45
|
# If you want to apply new code when deployed,
|
34
46
|
# please invoke this task after deploy:published
|
35
47
|
desc "Attach listener and application configuration to NGINX Unit"
|
@@ -74,14 +86,26 @@ namespace :nginx_unit do
|
|
74
86
|
desc "Detach listener configuration from NGINX Unit"
|
75
87
|
task :detach_listener do
|
76
88
|
on release_roles(fetch(:nginx_unit_roles)) do
|
77
|
-
|
89
|
+
listen = fetch(:nginx_unit_listen)
|
90
|
+
|
91
|
+
if nginx_unit_conf["listeners"][listen]
|
92
|
+
control_nginx_unit(:delete, path: "/listeners/#{listen}")
|
93
|
+
else
|
94
|
+
info "Listener \"#{listen}\" is already detached"
|
95
|
+
end
|
78
96
|
end
|
79
97
|
end
|
80
98
|
|
81
99
|
desc "Detach application configuration from NGINX Unit"
|
82
100
|
task :detach_app do
|
83
101
|
on release_roles(fetch(:nginx_unit_roles)) do
|
84
|
-
|
102
|
+
app_name = fetch(:nginx_unit_app_name)
|
103
|
+
|
104
|
+
if nginx_unit_conf["applications"][app_name]
|
105
|
+
control_nginx_unit(:delete, path: "/applications/#{app_name}")
|
106
|
+
else
|
107
|
+
info "Application \"#{app_name}\" is already detached"
|
108
|
+
end
|
85
109
|
end
|
86
110
|
end
|
87
111
|
|
@@ -98,4 +122,13 @@ namespace :nginx_unit do
|
|
98
122
|
|
99
123
|
execute :curl, *args
|
100
124
|
end
|
125
|
+
|
126
|
+
# Get current configuration
|
127
|
+
def nginx_unit_conf
|
128
|
+
JSON.parse(capture(
|
129
|
+
:curl,
|
130
|
+
"--unix-socket #{fetch(:nginx_unit_control_sock)}",
|
131
|
+
"http://localhost/"
|
132
|
+
))
|
133
|
+
end
|
101
134
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- murakmii
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|