kanrisuru-nginx 0.1.0 → 0.2.0
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/.rubocop.yml +62 -7
- data/CHANGELOG.md +4 -4
- data/Gemfile +1 -9
- data/README.md +164 -6
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/kanrisuru-nginx.gemspec +5 -6
- data/lib/kanrisuru/nginx.rb +16 -3
- data/lib/kanrisuru/nginx/package.rb +113 -0
- data/lib/kanrisuru/nginx/service.rb +97 -0
- data/lib/kanrisuru/nginx/signal.rb +13 -0
- data/lib/kanrisuru/nginx/version.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bba2b97f8861c1068bca148978a979b97f402f7720acf882c1669cd98a5df176
|
4
|
+
data.tar.gz: 7846c49f88a0693ec738f7c4e04227e5c980f3c9cfa04003f012f331380d1f22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a74bcd06e769edfc2d7825ca623308a8723dd7687afbcd12be1f1414ac64e167d2c937400fa38602120de9d92729f4c1f43e7b8cd65fb345e83b105135d9e62d
|
7
|
+
data.tar.gz: 5b0101ab11d8c725eb7f83274f9f8c7f85de6c481caace11228f40092d9949ef230abbd0faf24c4241414a389714fd79dbc97666d296234567a430a6e737d74f
|
data/.rubocop.yml
CHANGED
@@ -1,13 +1,68 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
1
3
|
AllCops:
|
2
|
-
|
4
|
+
NewCops: enable
|
5
|
+
SuggestExtensions: false
|
3
6
|
|
4
7
|
Style/StringLiterals:
|
5
8
|
Enabled: true
|
6
|
-
EnforcedStyle:
|
9
|
+
EnforcedStyle: single_quotes
|
7
10
|
|
8
|
-
Style/
|
9
|
-
Enabled:
|
10
|
-
|
11
|
+
Style/Documentation:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Style/WordArray:
|
15
|
+
Exclude:
|
16
|
+
- lib/kanrisuru/util/dmi_type.rb
|
17
|
+
|
18
|
+
Lint/SymbolConversion:
|
19
|
+
Exclude:
|
20
|
+
- lib/kanrisuru/util/dmi_type.rb
|
21
|
+
|
22
|
+
Naming/InclusiveLanguage:
|
23
|
+
Exclude:
|
24
|
+
- lib/kanrisuru/core/dmi.rb
|
25
|
+
- spec/unit/core/dmi_spec.rb
|
26
|
+
|
27
|
+
Naming/MethodParameterName:
|
28
|
+
Exclude:
|
29
|
+
- spec/functional/os_package_spec.rb
|
30
|
+
|
31
|
+
Metrics/AbcSize:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Metrics/CyclomaticComplexity:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Metrics/PerceivedComplexity:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Metrics/MethodLength:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Metrics/ClassLength:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
Metrics/ModuleLength:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Metrics/BlockLength:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
Lint/ConstantDefinitionInBlock:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
RSpec/FilePath:
|
56
|
+
SpecSuffixOnly: true
|
57
|
+
|
58
|
+
RSpec/ExampleLength:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
RSpec/MultipleExpectations:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
RSpec/BeforeAfterAll:
|
65
|
+
Enabled: false
|
11
66
|
|
12
|
-
|
13
|
-
|
67
|
+
RSpec/LeakyConstantDeclaration:
|
68
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Kanrisuru::Nginx
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This project helps you manage your remote Nginx webservers. Built ontop of the [Kanrisuru library](https://github.com/avamia/kanrisuru), it utilizes the core set of commands to install, service and configure the Nginx webserver.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,8 +20,168 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
The nginx module is namespaced on a `host` and `cluster` instance under the `nginx` name.
|
24
|
+
|
25
|
+
### Requirment
|
26
|
+
|
27
|
+
To use `Kanrisuru::Nginx` in your project, make sure to include both projects to manage the infrastructure.
|
28
|
+
```ruby
|
29
|
+
require 'kanrisuru'
|
30
|
+
require 'kanrisuru-nginx'
|
31
|
+
```
|
32
|
+
|
33
|
+
Most commands with nginx need to be run as root, so don't forget to call the `su` method before running the nginx module.
|
34
|
+
|
35
|
+
### Package Installation
|
36
|
+
Installation of the nginx package is straightforward. You can check if the package is installed directly with the `installed?` method.
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
host.su('root')
|
40
|
+
host = Kanrisuru::Remote::Host.new(host: 'centos-host', username: 'centos', keys: ['~/.ssh/id-rsa'])
|
41
|
+
|
42
|
+
host.nginx.installed?
|
43
|
+
# => false
|
44
|
+
|
45
|
+
result = host.nginx.install
|
46
|
+
result.success?
|
47
|
+
# => true
|
48
|
+
|
49
|
+
host.nginx.installed?
|
50
|
+
# => true
|
51
|
+
```
|
52
|
+
|
53
|
+
The installation is installed via the `apt`, `yum`, and `zypper` package managers for their respective linux distribution types, namely:
|
54
|
+
| Package Manager | OS Distro |
|
55
|
+
|-----------------|-----------|
|
56
|
+
| `apt` | debian |
|
57
|
+
| `apt` | ubuntu |
|
58
|
+
| `yum` | centos |
|
59
|
+
| `yum` | redhat |
|
60
|
+
| `yum` | fedora |
|
61
|
+
| `zypper` | opensuse |
|
62
|
+
| `zypper` | SUSE Enterprise Linux |
|
63
|
+
|
64
|
+
With Kanrisuru, the `os_include` and `os_define` takes care of figuring out which linux distro and release should be used with the corresponding install method, so you only need to call `host.nginx.install` for it to work.
|
65
|
+
|
66
|
+
### Package Removal
|
67
|
+
To remove an installed version of Nginx, call:
|
68
|
+
```ruby
|
69
|
+
host.nginx.installed?
|
70
|
+
# => true
|
71
|
+
|
72
|
+
host.nginx.remove
|
73
|
+
|
74
|
+
host.nginx.installed?
|
75
|
+
# => false
|
76
|
+
```
|
77
|
+
|
78
|
+
Note that if Nginx is running while calling remove, it will automatically stop any master / worker processes that are running before removing the package.
|
79
|
+
|
80
|
+
### Service Methods
|
81
|
+
To service the nginx webserver, the following commands help you easily start, stop, and restart the webserver
|
82
|
+
```ruby
|
83
|
+
host.nginx.running?
|
84
|
+
# => false
|
26
85
|
|
86
|
+
## Start the webserver
|
87
|
+
result = host.nginx.start
|
88
|
+
result.success?
|
89
|
+
# => true
|
90
|
+
|
91
|
+
host.nginx.running?
|
92
|
+
# => true
|
93
|
+
|
94
|
+
host.nginx.master_pid
|
95
|
+
# => 1337
|
96
|
+
|
97
|
+
result = host.nginx.restart
|
98
|
+
result.success?
|
99
|
+
# => true
|
100
|
+
|
101
|
+
host.nginx.master_pid
|
102
|
+
# => 4343
|
103
|
+
|
104
|
+
result = host.nginx.stop
|
105
|
+
result.success?
|
106
|
+
# => true
|
107
|
+
|
108
|
+
host.nginx.running?
|
109
|
+
# => false
|
110
|
+
```
|
111
|
+
|
112
|
+
You can test to see if the current configuration files are properly formatted
|
113
|
+
```ruby
|
114
|
+
result = host.nginx.test
|
115
|
+
result.success?
|
116
|
+
# => true
|
117
|
+
|
118
|
+
result = host.nginx.test(config: '~/test.conf')
|
119
|
+
result.success?
|
120
|
+
# => true
|
121
|
+
```
|
122
|
+
|
123
|
+
To reload the nginx workers with updated configuration files, but not a full restart
|
124
|
+
```ruby
|
125
|
+
host.nginx.master_pid
|
126
|
+
# => 4343
|
127
|
+
|
128
|
+
result = host.nginx.reload
|
129
|
+
result.success?
|
130
|
+
# => true
|
131
|
+
|
132
|
+
host.nginx.master_pid
|
133
|
+
# => 4343
|
134
|
+
```
|
135
|
+
|
136
|
+
### Configuration Management
|
137
|
+
This is currently in development and is the focus of the next release for this module.
|
138
|
+
|
139
|
+
### Utilities
|
140
|
+
You can fetch the master and worker process information
|
141
|
+
```ruby
|
142
|
+
host.nginx.master_process
|
143
|
+
#<Struct:Kanrisuru::Core::System::ProcessInfo:0x000005f0
|
144
|
+
ppid = 1,
|
145
|
+
command = "nginx: master process nginx",
|
146
|
+
cpu_time = "00:00:00",
|
147
|
+
cpu_usage = 0.0,
|
148
|
+
flags = 1,
|
149
|
+
gid = 0,
|
150
|
+
group = "root",
|
151
|
+
memory_usage = 0.0,
|
152
|
+
pid = 20484,
|
153
|
+
policy = "SCHED_OTHER",
|
154
|
+
policy_abbr = "TS",
|
155
|
+
priority = 19,
|
156
|
+
stat = "Ss",
|
157
|
+
uid = 0,
|
158
|
+
user = "root"
|
159
|
+
>
|
160
|
+
|
161
|
+
host.nginx.master_pid
|
162
|
+
# => 20484
|
163
|
+
|
164
|
+
host.nginx.worker_processess
|
165
|
+
[
|
166
|
+
#<Struct:Kanrisuru::Core::System::ProcessInfo:0x0000f4d8
|
167
|
+
ppid = 20484,
|
168
|
+
command = "nginx: worker process",
|
169
|
+
cpu_time = "00:00:00",
|
170
|
+
cpu_usage = 0.0,
|
171
|
+
flags = 5,
|
172
|
+
gid = 994,
|
173
|
+
group = "nginx",
|
174
|
+
memory_usage = 0.0,
|
175
|
+
pid = 20485,
|
176
|
+
policy = "SCHED_OTHER",
|
177
|
+
policy_abbr = "TS",
|
178
|
+
priority = 19,
|
179
|
+
stat = "S",
|
180
|
+
uid = 997,
|
181
|
+
user = "nginx"
|
182
|
+
>
|
183
|
+
]
|
184
|
+
```
|
27
185
|
## Development
|
28
186
|
|
29
187
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -32,7 +190,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
190
|
|
33
191
|
## Contributing
|
34
192
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
193
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/avamia/kanrisuru-nginx. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/avamia/kanrisuru-nginx/blob/master/CODE_OF_CONDUCT.md).
|
36
194
|
|
37
195
|
## License
|
38
196
|
|
@@ -40,4 +198,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
198
|
|
41
199
|
## Code of Conduct
|
42
200
|
|
43
|
-
Everyone interacting in the Kanrisuru::Nginx project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
201
|
+
Everyone interacting in the Kanrisuru::Nginx project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/avamia/kanrisuru-nginx/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
require
|
8
|
+
require 'rubocop/rake_task'
|
9
9
|
|
10
10
|
RuboCop::RakeTask.new
|
11
11
|
|
data/bin/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'kanrisuru/nginx'
|
6
6
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -11,5 +11,5 @@ require "kanrisuru/nginx"
|
|
11
11
|
# require "pry"
|
12
12
|
# Pry.start
|
13
13
|
|
14
|
-
require
|
14
|
+
require 'irb'
|
15
15
|
IRB.start(__FILE__)
|
data/kanrisuru-nginx.gemspec
CHANGED
@@ -8,20 +8,20 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.author = 'Ryan Mammina'
|
9
9
|
gem.email = 'ryan@avamia.com'
|
10
10
|
gem.license = 'MIT'
|
11
|
-
gem.summary = 'Manage nginx webservers with kanrisuru.'
|
12
|
-
gem.description = 'Manage nginx webservers with kanrisuru.'
|
11
|
+
gem.summary = 'Manage remote nginx webservers with kanrisuru.'
|
12
|
+
gem.description = 'Manage remote nginx webservers with kanrisuru.'
|
13
13
|
gem.homepage = 'https://github.com/avamia/kanrisuru-nginx'
|
14
14
|
|
15
|
-
gem.required_ruby_version =
|
15
|
+
gem.required_ruby_version = '>= 2.5.0'
|
16
16
|
|
17
17
|
gem.files = Dir.chdir(File.expand_path(__dir__)) do
|
18
18
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
19
19
|
end
|
20
20
|
|
21
21
|
gem.executables = gem.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
22
|
-
gem.require_paths = [
|
22
|
+
gem.require_paths = ['lib']
|
23
23
|
|
24
|
-
gem.add_dependency
|
24
|
+
gem.add_dependency 'kanrisuru', '~> 0.7.3'
|
25
25
|
|
26
26
|
gem.add_development_dependency 'rspec', '~> 3.10'
|
27
27
|
gem.add_development_dependency 'rubocop', '~> 1.12'
|
@@ -33,5 +33,4 @@ Gem::Specification.new do |gem|
|
|
33
33
|
'changelog_uri' => 'https://github.com/avamia/kanrisuru-nginx/blob/master/CHANGELOG.md',
|
34
34
|
'homepage_uri' => gem.homepage
|
35
35
|
}
|
36
|
-
|
37
36
|
end
|
data/lib/kanrisuru/nginx.rb
CHANGED
@@ -1,10 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'nginx/version'
|
4
|
+
require_relative 'nginx/signal'
|
5
|
+
require_relative 'nginx/package'
|
6
|
+
require_relative 'nginx/service'
|
4
7
|
|
5
8
|
module Kanrisuru
|
6
9
|
module Nginx
|
7
|
-
|
8
|
-
|
10
|
+
end
|
11
|
+
|
12
|
+
module Remote
|
13
|
+
class Host
|
14
|
+
os_include Kanrisuru::Nginx::Package, namespace: :nginx
|
15
|
+
os_include Kanrisuru::Nginx::Service, namespace: :nginx
|
16
|
+
end
|
17
|
+
|
18
|
+
class Cluster
|
19
|
+
os_collection Kanrisuru::Nginx::Package, namespace: :nginx
|
20
|
+
os_collection Kanrisuru::Nginx::Service, namespace: :nginx
|
21
|
+
end
|
9
22
|
end
|
10
23
|
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Nginx
|
5
|
+
module Package
|
6
|
+
extend OsPackage::Define
|
7
|
+
|
8
|
+
os_define :linux, :version
|
9
|
+
|
10
|
+
os_define :debian, :apt_installed?, alias: :installed?
|
11
|
+
os_define :fedora, :yum_installed?, alias: :installed?
|
12
|
+
os_define :sles, :zypper_installed?, alias: :installed?
|
13
|
+
|
14
|
+
os_define :debian, :apt_install, alias: :install
|
15
|
+
os_define :fedora, :yum_install, alias: :install
|
16
|
+
os_define :sles, :zypper_install, alias: :install
|
17
|
+
|
18
|
+
os_define :debian, :apt_update, alias: :update
|
19
|
+
os_define :fedora, :yum_update, alias: :update
|
20
|
+
os_define :sles, :zypper_update, alias: :update
|
21
|
+
|
22
|
+
os_define :debian, :apt_remove, alias: :remove
|
23
|
+
os_define :fedora, :yum_remove, alias: :remove
|
24
|
+
os_define :sles, :zypper_remove, alias: :remove
|
25
|
+
|
26
|
+
def apt_installed?
|
27
|
+
result = @host.apt('list', installed: true, packages: ['nginx'])
|
28
|
+
return false if result.failure?
|
29
|
+
|
30
|
+
package = result.find { |item| item.package == 'nginx' }
|
31
|
+
Kanrisuru::Util.present?(package) && package.installed == true
|
32
|
+
end
|
33
|
+
|
34
|
+
def yum_installed?
|
35
|
+
result = @host.yum('list', installed: true, query: 'nginx')
|
36
|
+
return false if result.failure?
|
37
|
+
|
38
|
+
package = result.find { |item| item.package == 'nginx' }
|
39
|
+
Kanrisuru::Util.present?(package)
|
40
|
+
end
|
41
|
+
|
42
|
+
def zypper_installed?
|
43
|
+
result = @host.zypper('info', packages: ['nginx'])
|
44
|
+
return false if result.failure?
|
45
|
+
|
46
|
+
package = result.find { |item| item.package == 'nginx' }
|
47
|
+
Kanrisuru::Util.present?(package) && package.installed == true
|
48
|
+
end
|
49
|
+
|
50
|
+
def version
|
51
|
+
command = Kanrisuru::Command.new('nginx -v')
|
52
|
+
|
53
|
+
@host.execute_shell(command)
|
54
|
+
|
55
|
+
Kanrisuru::Result.new(command) do |cmd|
|
56
|
+
values = cmd.to_s.split('/')
|
57
|
+
values[1].to_f
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def apt_install
|
62
|
+
@host.apt('install', packages: ['nginx'])
|
63
|
+
end
|
64
|
+
|
65
|
+
def yum_install
|
66
|
+
@host.yum('install', packages: ['nginx'])
|
67
|
+
end
|
68
|
+
|
69
|
+
def zypper_install
|
70
|
+
@host.zypper('install', packages: ['nginx'])
|
71
|
+
end
|
72
|
+
|
73
|
+
def apt_update
|
74
|
+
@host.apt('update')
|
75
|
+
end
|
76
|
+
|
77
|
+
def yum_update
|
78
|
+
@host.yum('update')
|
79
|
+
end
|
80
|
+
|
81
|
+
def zypper_update
|
82
|
+
@host.zypper('update')
|
83
|
+
end
|
84
|
+
|
85
|
+
def apt_remove
|
86
|
+
if @host.nginx.running?
|
87
|
+
result = @host.nginx.stop
|
88
|
+
return result unless result.success?
|
89
|
+
end
|
90
|
+
|
91
|
+
@host.apt('purge', packages: %w[nginx nginx-common])
|
92
|
+
end
|
93
|
+
|
94
|
+
def yum_remove
|
95
|
+
if @host.nginx.running?
|
96
|
+
result = @host.nginx.stop
|
97
|
+
return result unless result.success?
|
98
|
+
end
|
99
|
+
|
100
|
+
@host.yum('remove', packages: ['nginx'])
|
101
|
+
end
|
102
|
+
|
103
|
+
def zypper_remove
|
104
|
+
if @host.nginx.running?
|
105
|
+
result = @host.nginx.stop
|
106
|
+
return result unless result.success?
|
107
|
+
end
|
108
|
+
|
109
|
+
@host.zypper('remove', packages: ['nginx'])
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Nginx
|
5
|
+
module Service
|
6
|
+
extend OsPackage::Define
|
7
|
+
|
8
|
+
os_define :linux, :start
|
9
|
+
os_define :linux, :stop
|
10
|
+
os_define :linux, :quit
|
11
|
+
os_define :linux, :restart
|
12
|
+
os_define :linux, :reload
|
13
|
+
os_define :linux, :test
|
14
|
+
|
15
|
+
os_define :linux, :running?
|
16
|
+
os_define :linux, :master_process
|
17
|
+
os_define :linux, :master_pid
|
18
|
+
os_define :linux, :worker_processess
|
19
|
+
|
20
|
+
def start(opts = {})
|
21
|
+
command = Kanrisuru::Command.new('nginx')
|
22
|
+
command.append_arg('-c', opts[:config])
|
23
|
+
|
24
|
+
@host.execute_shell(command)
|
25
|
+
|
26
|
+
Kanrisuru::Result.new(command)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test(opts = {})
|
30
|
+
command = Kanrisuru::Command.new('nginx')
|
31
|
+
command.append_arg('-c', opts[:config])
|
32
|
+
command.append_flag('-t')
|
33
|
+
|
34
|
+
@host.execute_shell(command)
|
35
|
+
|
36
|
+
Kanrisuru::Result.new(command)
|
37
|
+
end
|
38
|
+
|
39
|
+
def stop
|
40
|
+
command = Kanrisuru::Command.new('nginx')
|
41
|
+
command.append_arg('-s', 'stop')
|
42
|
+
|
43
|
+
@host.execute_shell(command)
|
44
|
+
|
45
|
+
Kanrisuru::Result.new(command)
|
46
|
+
end
|
47
|
+
|
48
|
+
def restart(opts = {})
|
49
|
+
return false unless running?
|
50
|
+
|
51
|
+
result = stop
|
52
|
+
return false unless result.success?
|
53
|
+
|
54
|
+
start(opts)
|
55
|
+
end
|
56
|
+
|
57
|
+
def reload(opts = {})
|
58
|
+
command = Kanrisuru::Command.new('nginx')
|
59
|
+
command.append_arg('-c', opts[:config])
|
60
|
+
command.append_arg('-s', 'reload')
|
61
|
+
|
62
|
+
@host.execute_shell(command)
|
63
|
+
|
64
|
+
Kanrisuru::Result.new(command)
|
65
|
+
end
|
66
|
+
|
67
|
+
def running?
|
68
|
+
process = master_process
|
69
|
+
return false if !process || process.instance_of?(Kanrisuru::Result)
|
70
|
+
|
71
|
+
process.respond_to?(:pid) &&
|
72
|
+
process.pid >= 0
|
73
|
+
end
|
74
|
+
|
75
|
+
def master_process
|
76
|
+
result = @host.ps
|
77
|
+
return result if result.failure?
|
78
|
+
|
79
|
+
result.find { |process| process.command.include?('nginx: master') }
|
80
|
+
end
|
81
|
+
|
82
|
+
def master_pid
|
83
|
+
process = master_process
|
84
|
+
return unless process.instance_of?(Kanrisuru::Core::System::ProcessInfo)
|
85
|
+
|
86
|
+
process.pid
|
87
|
+
end
|
88
|
+
|
89
|
+
def worker_processess
|
90
|
+
result = @host.ps
|
91
|
+
return result if result.failure?
|
92
|
+
|
93
|
+
result.select { |process| process.command.include?('nginx: worker') }
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanrisuru-nginx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mammina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kanrisuru
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.7.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.7.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.21'
|
83
|
-
description: Manage nginx webservers with kanrisuru.
|
83
|
+
description: Manage remote nginx webservers with kanrisuru.
|
84
84
|
email: ryan@avamia.com
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
@@ -99,6 +99,9 @@ files:
|
|
99
99
|
- bin/setup
|
100
100
|
- kanrisuru-nginx.gemspec
|
101
101
|
- lib/kanrisuru/nginx.rb
|
102
|
+
- lib/kanrisuru/nginx/package.rb
|
103
|
+
- lib/kanrisuru/nginx/service.rb
|
104
|
+
- lib/kanrisuru/nginx/signal.rb
|
102
105
|
- lib/kanrisuru/nginx/version.rb
|
103
106
|
homepage: https://github.com/avamia/kanrisuru-nginx
|
104
107
|
licenses:
|
@@ -125,5 +128,5 @@ requirements: []
|
|
125
128
|
rubygems_version: 3.1.2
|
126
129
|
signing_key:
|
127
130
|
specification_version: 4
|
128
|
-
summary: Manage nginx webservers with kanrisuru.
|
131
|
+
summary: Manage remote nginx webservers with kanrisuru.
|
129
132
|
test_files: []
|