nginx-server 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +19 -0
- data/examples/0.rb +11 -0
- data/examples/nginx.conf.erb +22 -0
- data/lib/nginx/server.rb +43 -0
- data/nginx-server.gemspec +9 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 98107dc1a5a370fcc90168e74eb0408fcf9ac84c06161dd04ccbb7e665fc049d
|
4
|
+
data.tar.gz: cb2ac11c851173ef82d2368f4d49d64b6318bb05b904a8eb07e193d253551e86
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7e4cd3edb4f0044508d37b9029b47ef6f8c5daf4c74f68decab57209e54568bcdf0af312de91ae424ca541990582671fe7d5d25e853dd11c9ec2e7e74c6413cf
|
7
|
+
data.tar.gz: 73460b49c80da4fc4cd7949102c575add1e7e5f21aba46c68a9556e860b18c49a1bd15dceae487a653a87c3458b180ba96a9d8d0f46b33c13b8f7ca7e7b9c956
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/examples/0.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
events {
|
2
|
+
worker_connections 1024;
|
3
|
+
}
|
4
|
+
|
5
|
+
error_log <%= error_log %>;
|
6
|
+
pid <%= pid %>;
|
7
|
+
|
8
|
+
http {
|
9
|
+
access_log <%= access_log %>;
|
10
|
+
|
11
|
+
upstream first_upstream {
|
12
|
+
server unix:<%= first_upstream %>;
|
13
|
+
}
|
14
|
+
|
15
|
+
server {
|
16
|
+
listen 127.0.0.1:8080;
|
17
|
+
|
18
|
+
location /first/ {
|
19
|
+
proxy_pass http://first_upstream/;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
data/lib/nginx/server.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'pathname'
|
3
|
+
require 'erb'
|
4
|
+
require 'suppress_output'
|
5
|
+
|
6
|
+
module Nginx
|
7
|
+
class Server
|
8
|
+
def initialize template,
|
9
|
+
dir: "/tmp/nginx.#{Process.pid}.#{SecureRandom.uuid}"
|
10
|
+
@dir = Pathname dir; @dir.mkpath
|
11
|
+
create_config template
|
12
|
+
end
|
13
|
+
|
14
|
+
def start
|
15
|
+
@nginx_pid = suppress_output do
|
16
|
+
spawn "nginx -c nginx.conf -p #{@dir} -g 'daemon off;'"
|
17
|
+
end; at_exit { stop }
|
18
|
+
@nginx_pid
|
19
|
+
end
|
20
|
+
|
21
|
+
def stop
|
22
|
+
`kill #{@nginx_pid}`
|
23
|
+
end
|
24
|
+
|
25
|
+
def error_log
|
26
|
+
'error.log'
|
27
|
+
end
|
28
|
+
|
29
|
+
def access_log
|
30
|
+
'access.log'
|
31
|
+
end
|
32
|
+
|
33
|
+
def pid
|
34
|
+
'nginx.pid'
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def create_config template
|
39
|
+
string = ERB.new(IO.read template).result(binding)
|
40
|
+
IO.write "#{@dir}/nginx.conf", string
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nginx-server
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anatoly Chernow
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: suppress_output
|
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
|
+
description:
|
28
|
+
email:
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- Gemfile
|
34
|
+
- Gemfile.lock
|
35
|
+
- examples/0.rb
|
36
|
+
- examples/nginx.conf.erb
|
37
|
+
- lib/nginx/server.rb
|
38
|
+
- nginx-server.gemspec
|
39
|
+
homepage:
|
40
|
+
licenses: []
|
41
|
+
metadata: {}
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 2.7.6
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
61
|
+
summary: Manage Nginx servers from Ruby.
|
62
|
+
test_files: []
|