Thin_Upstreams 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +60 -16
- data/Thin_Upstreams.gemspec +1 -1
- data/lib/Thin_Upstreams/version.rb +1 -1
- data/lib/Thin_Upstreams.rb +1 -1
- data/spec/main.rb +20 -18
- data/spec/tests/bin.rb +2 -2
- metadata +4 -4
data/README.md
CHANGED
@@ -2,45 +2,89 @@
|
|
2
2
|
Thin\_Upstreams
|
3
3
|
================
|
4
4
|
|
5
|
-
A Ruby gem to generate .conf files with upstreams
|
5
|
+
A Ruby gem to generate partial .conf files with upstreams
|
6
6
|
to include in your nginx.conf. It uses your Thin
|
7
|
-
configuration files.
|
7
|
+
.yml configuration files.
|
8
|
+
|
9
|
+
Assuming you have a directory structure of:
|
10
|
+
|
11
|
+
/cwd (current working directory)
|
12
|
+
|-- Hi/config/thin.yml (port 6010, servers 3)
|
13
|
+
|-- Hello/config/thin.yml (port 7000, servers 2)
|
14
|
+
|
15
|
+
The file would be generated as `/cwd/upstreams.conf`:
|
16
|
+
|
17
|
+
upstream Hi {
|
18
|
+
server 127.0.0.1:6010;
|
19
|
+
server 127.0.0.1:6011;
|
20
|
+
server 127.0.0.1:6012;
|
21
|
+
}
|
22
|
+
|
23
|
+
upstream Hello {
|
24
|
+
server 127.0.0.1:7000;
|
25
|
+
server 127.0.0.1:7001;
|
26
|
+
}
|
27
|
+
|
28
|
+
Then, in your nginx.conf:
|
29
|
+
|
30
|
+
# ... your other settings
|
31
|
+
|
32
|
+
http {
|
33
|
+
|
34
|
+
# ... your other settings
|
35
|
+
|
36
|
+
include /cwd/upstreams.conf;
|
37
|
+
|
38
|
+
server {
|
39
|
+
|
40
|
+
location / {
|
41
|
+
proxy_pass http://Hi;
|
42
|
+
}
|
43
|
+
|
44
|
+
location /sub {
|
45
|
+
proxy_pass http://Hello;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
8
50
|
|
9
51
|
Installation
|
10
52
|
------------
|
11
53
|
|
12
|
-
gem
|
54
|
+
gem install Thin_Upstreams
|
55
|
+
|
56
|
+
Note: Output File
|
57
|
+
----
|
58
|
+
|
59
|
+
* Output file name: `upstreams.conf`
|
60
|
+
* You can't specify file output name.
|
61
|
+
* File is overwritten. No safety checks or warnings.
|
13
62
|
|
14
|
-
Notes
|
15
|
-
-----
|
16
|
-
|
17
|
-
File upstreams.conf is created in current working directory.
|
18
|
-
You can't specify file output name.
|
19
63
|
|
20
64
|
Usage: In Ruby
|
21
65
|
------
|
22
66
|
|
23
|
-
Accepts optional file
|
67
|
+
Accepts optional file glob:
|
24
68
|
|
25
69
|
require "Thin_Upstreams"
|
26
70
|
|
27
|
-
Dir.chdir("/
|
71
|
+
Dir.chdir("/my_apps") {
|
28
72
|
Thin_Upstreams()
|
29
|
-
Thin_Upstreams "*/configs/my.thin.yml"
|
73
|
+
Thin_Upstreams "*/configs/my.thin.yml"
|
30
74
|
}
|
31
75
|
|
32
|
-
File /
|
76
|
+
File /my\_apps/upstreams.conf is created/overwritten.
|
33
77
|
|
34
78
|
Usage: Bash/Shell
|
35
79
|
------
|
36
80
|
|
37
|
-
File glob
|
81
|
+
File glob argument is optional:
|
38
82
|
|
39
|
-
cd /
|
83
|
+
cd /my_apps
|
40
84
|
Thin_Upstreams
|
41
|
-
Thin_Upstreams "*/configs/my.thin.yml"
|
85
|
+
Thin_Upstreams "*/configs/my.thin.yml"
|
42
86
|
|
43
|
-
File /
|
87
|
+
File /my\_app/upstreams.conf is created/overwritten.
|
44
88
|
|
45
89
|
Run Tests
|
46
90
|
---------
|
data/Thin_Upstreams.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
|
-
s.add_development_dependency '
|
24
|
+
s.add_development_dependency 'Exit_0'
|
25
25
|
s.add_development_dependency 'bacon'
|
26
26
|
s.add_development_dependency 'rake'
|
27
27
|
s.add_development_dependency 'Bacon_Colored'
|
data/lib/Thin_Upstreams.rb
CHANGED
data/spec/main.rb
CHANGED
@@ -3,40 +3,42 @@ require File.expand_path('spec/helper')
|
|
3
3
|
require 'Thin_Upstreams'
|
4
4
|
require 'Bacon_Colored'
|
5
5
|
require 'pry'
|
6
|
-
require '
|
6
|
+
require 'Exit_0'
|
7
7
|
|
8
8
|
DIR = "/tmp/Thin_Upstreams"
|
9
9
|
|
10
|
+
def chdir
|
11
|
+
Dir.chdir(DIR) {
|
12
|
+
yield
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
10
16
|
def reset_dir
|
11
|
-
|
17
|
+
Exit_0 "rm -rf #{DIR}"
|
12
18
|
|
13
|
-
|
14
|
-
|
19
|
+
Exit_0 "mkdir -p #{DIR}/Hi/config"
|
20
|
+
Exit_0 "mkdir -p #{DIR}/Hi/custom"
|
15
21
|
|
16
|
-
|
17
|
-
|
22
|
+
Exit_0 "mkdir -p #{DIR}/Hello/config"
|
23
|
+
Exit_0 "mkdir -p #{DIR}/Hello/custom"
|
18
24
|
|
19
25
|
chdir {
|
20
|
-
|
21
|
-
|
26
|
+
Exit_0 "cd Hi/config && bundle exec thin config -C thin.yml --port 3010 --servers 2"
|
27
|
+
Exit_0 "cd Hello/config && bundle exec thin config -C thin.yml --port 4010 --servers 3"
|
22
28
|
|
23
|
-
|
24
|
-
|
29
|
+
Exit_0 "cd Hi/custom && bundle exec thin config -C my.yml --port 6010 --servers 4"
|
30
|
+
Exit_0 "cd Hello/custom && bundle exec thin config -C my.yml --port 7010 --servers 5"
|
25
31
|
}
|
26
32
|
end
|
27
33
|
|
34
|
+
reset_dir
|
35
|
+
|
28
36
|
def reset_file
|
29
37
|
chdir {
|
30
38
|
file = "upstreams.conf"
|
31
39
|
nginx = "nginx.conf"
|
32
|
-
|
33
|
-
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
def chdir
|
38
|
-
Dir.chdir(DIR) {
|
39
|
-
yield
|
40
|
+
Exit_0 "rm #{file}" if File.exists?(file)
|
41
|
+
Exit_0 "rm #{nginx}" if File.exists?(nginx)
|
40
42
|
}
|
41
43
|
end
|
42
44
|
|
data/spec/tests/bin.rb
CHANGED
@@ -17,7 +17,7 @@ describe "Thin_Upstreams (bin executable)" do
|
|
17
17
|
it "creates upstreams.conf file" do
|
18
18
|
target = "upstream Hi"
|
19
19
|
chdir {
|
20
|
-
|
20
|
+
Exit_0 "Thin_Upstreams"
|
21
21
|
File.read("upstreams.conf")[target].should == target
|
22
22
|
}
|
23
23
|
end
|
@@ -25,7 +25,7 @@ describe "Thin_Upstreams (bin executable)" do
|
|
25
25
|
it "accepts a file glob" do
|
26
26
|
target = ":601"
|
27
27
|
chdir {
|
28
|
-
|
28
|
+
Exit_0 "Thin_Upstreams \"*/custom/*.yml\""
|
29
29
|
File.read("upstreams.conf")[target].should == target
|
30
30
|
}
|
31
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Thin_Upstreams
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: Exit_0
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 1.8.
|
152
|
+
rubygems_version: 1.8.23
|
153
153
|
signing_key:
|
154
154
|
specification_version: 3
|
155
155
|
summary: Create upstreams conf file for Nginx.
|