fontana_client_support 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/fontana_config_server +21 -0
- data/lib/fontana_client_support/config_server.rb +38 -10
- data/lib/fontana_client_support/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDA5MjJjNTViZjRiNjk1MmQ0Y2MwOWQyNDcwZTA1MWMxOTU5YjgyZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjJkYWE4MTg3MTdmNjg3N2U2ZTJiYTliNjMwZDQ5OWE0MjZkMWM5Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjNiNmM0YTUxMjEzMTZjOGU0NjE1ZTc4ZjA1NDkyZTIxNDI4NjlhZTM5ZDNh
|
10
|
+
ZDFmMmZkOWY0MTRkNDBkMzBhY2Y4YTM5OWY0MDczMDQyMmIyMzBlNGFiNmMw
|
11
|
+
M2JmNjBhYTY2NTYzMmNhMGViMTkxZTVjZjg5NWU5ZjRjYmE5YjA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzVmNDI5M2UwODQ2NTRhNWYzZDUyMmY2NDVkNjczMTU5NDEzMjI4MTE2Yzc1
|
14
|
+
ZDQ1YWFhZThhNGM3MjU2MWY1NjVkMWVjMTg0OTBkYjE0NTQzOGJkYTRiNDU3
|
15
|
+
MjZiNmRiODU5MTQ2M2M3ZGJkNzdkNGMyYjEzNjJhYjk5ZWMwMjc=
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH << File.expand_path("../../lib", __FILE__)
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
default_options = {
|
8
|
+
"port" => 3002,
|
9
|
+
}
|
10
|
+
banner = "%s [options]" % File.basename(__FILE__)
|
11
|
+
parser = OptionParser.new(banner) do |opt|
|
12
|
+
opt.on '-p', '--port PORT'
|
13
|
+
opt.on '-a', "--address BINDING_ADDRESS"
|
14
|
+
opt.on '-d', '--document-root DOCUMENT_ROOT_PATH'
|
15
|
+
end
|
16
|
+
|
17
|
+
options = default_options.merge(parser.getopts(ARGV))
|
18
|
+
options = options.each_with_object({}){|(k,v), d| d[k.gsub(/-/, '_').to_sym] = v}
|
19
|
+
|
20
|
+
require 'fontana_client_support'
|
21
|
+
FontanaClientSupport::ConfigServer.new(options).launch
|
@@ -1,24 +1,52 @@
|
|
1
1
|
require 'fontana_client_support'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'fileutils'
|
2
4
|
|
3
5
|
module FontanaClientSupport
|
4
6
|
class ConfigServer
|
5
7
|
|
6
8
|
# see http://doc.ruby-lang.org/ja/1.9.3/class/WEBrick=3a=3aHTTPServer.html
|
7
9
|
def initialize(config = {})
|
8
|
-
@config =
|
9
|
-
:DocumentRoot => File.join(FontanaClientSupport.root_dir, "config_server"),
|
10
|
-
:BindAddress => ENV['GSS_CONFIG_SERVER_ADDRESS'] || '127.0.0.1',
|
11
|
-
:Port => (ENV['GSS_CONFIG_SERVER_PORT'] || 80).to_i
|
12
|
-
}
|
13
|
-
@config.update(config)
|
10
|
+
@config = config
|
14
11
|
end
|
15
12
|
|
16
13
|
def launch
|
17
14
|
require 'webrick'
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
root_dir = FontanaClientSupport.root_dir
|
16
|
+
document_root_source = @config[:document_root] || root_dir ? File.join(root_dir, "config_server") : "."
|
17
|
+
Dir.mktmpdir("fontana_config_server") do |dir|
|
18
|
+
if @config[:document_root] or root_dir.nil?
|
19
|
+
document_root = document_root_source
|
20
|
+
else
|
21
|
+
git_dir = File.join(dir, "workspace")
|
22
|
+
document_root = File.join(dir, "document_root")
|
23
|
+
FileUtils.cp_r(document_root_source, document_root)
|
24
|
+
end
|
25
|
+
|
26
|
+
server_config = {
|
27
|
+
:DocumentRoot => document_root,
|
28
|
+
:BindAddress => @config[:address] || ENV['GSS_CONFIG_SERVER_ADDRESS'] || '127.0.0.1',
|
29
|
+
:Port => (@config[:port] || ENV['GSS_CONFIG_SERVER_PORT'] || 80).to_i
|
30
|
+
}
|
31
|
+
server = WEBrick::HTTPServer.new(server_config)
|
32
|
+
if FontanaClientSupport.root_dir
|
33
|
+
server.mount_proc('/switch_config_server') do |req, res|
|
34
|
+
unless Dir.exist?(git_dir)
|
35
|
+
FileUtils.cp_r(root_dir, git_dir)
|
36
|
+
end
|
37
|
+
tag = req.path.sub(%r{\A/switch_config_server/}, '')
|
38
|
+
Dir.chdir(git_dir) do
|
39
|
+
system("git reset --hard #{tag}")
|
40
|
+
FileUtils.rm_rf(document_root)
|
41
|
+
FileUtils.cp_r(File.join(git_dir, "config_server"), document_root)
|
42
|
+
end
|
43
|
+
res.body = Dir["#{document_root}/**/*"].to_a.join("\n ")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
puts "config_server options: #{@config.inspect}"
|
47
|
+
Signal.trap(:INT){ server.shutdown }
|
48
|
+
server.start
|
49
|
+
end
|
22
50
|
end
|
23
51
|
|
24
52
|
class << self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fontana_client_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,7 +83,8 @@ dependencies:
|
|
83
83
|
description: gem to support development and testing with GSS/fontana
|
84
84
|
email:
|
85
85
|
- t-akima@groovenauts.jp
|
86
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- fontana_config_server
|
87
88
|
extensions: []
|
88
89
|
extra_rdoc_files: []
|
89
90
|
files:
|
@@ -93,6 +94,7 @@ files:
|
|
93
94
|
- LICENSE.txt
|
94
95
|
- README.md
|
95
96
|
- Rakefile
|
97
|
+
- bin/fontana_config_server
|
96
98
|
- fontana_client_support.gemspec
|
97
99
|
- lib/fontana.rb
|
98
100
|
- lib/fontana/command_utils.rb
|