fontana_client_support 0.5.4 → 0.5.5
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 +8 -8
- data/lib/fontana_client_support/config_server.rb +34 -8
- data/lib/fontana_client_support/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTZhZWVhYzllN2JjM2FlYjcxMGRiMTVhM2RiNzhlODZkZmI5MGM3ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZWRhNjY1MTkyZDM1YWI5MjE0Yjk0ZWMwNzQxZWRiYTBlZGM1ZjlmZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTBjMGNhZGQ0N2IwZDdkM2M2ZWY1ZDg4M2U1MzE2MDM5MDdjNDhiMTQ0ZGU1
|
10
|
+
ZDA0ZjAyMDI4YTUzYWY2ZTI1NTgwN2JhNGFkN2Y2OGUxNWRlMDI0OTE2NGMy
|
11
|
+
Y2FhNmEyODI2ZDIxMjk4NzA4YWJhYzVjODM0OTg3YTkzZTE2M2E=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGFiZDE2MGE2ZGQwNTdmZTVlYmVkZjQxZmY3OTgyYTRiMTBjMjdkODc4ZWEy
|
14
|
+
Y2VlNjRiNDQ1OWM4MzUxODJhZjk5NjVjOWI2NDg3M2QzNjcyN2NhZDZmMDZl
|
15
|
+
ZmUxYTc3NWE3MGJiZDQ5OTgxODYyMGE1MjVmZTIyMjEwMDI3ZGE=
|
@@ -14,15 +14,21 @@ module FontanaClientSupport
|
|
14
14
|
require 'webrick'
|
15
15
|
root_dir = FontanaClientSupport.root_dir
|
16
16
|
document_root_source = @config[:document_root] || root_dir ? File.join(root_dir, "config_server") : "."
|
17
|
+
$stdout.puts "config_server options: #{@config.inspect}"
|
18
|
+
$stdout.puts("root_dir : #{root_dir.inspect}")
|
19
|
+
$stdout.puts("document_root_source : #{document_root_source.inspect}")
|
17
20
|
Dir.mktmpdir("fontana_config_server") do |dir|
|
18
21
|
if @config[:document_root] or root_dir.nil?
|
19
22
|
document_root = document_root_source
|
20
23
|
else
|
21
|
-
git_dir
|
24
|
+
git_dir = File.join(dir, "workspace")
|
22
25
|
document_root = File.join(dir, "document_root")
|
23
26
|
FileUtils.cp_r(document_root_source, document_root)
|
24
27
|
end
|
25
28
|
|
29
|
+
$stdout.puts("document_root : #{document_root.inspect}")
|
30
|
+
$stdout.puts("git_dir : #{git_dir.inspect}")
|
31
|
+
|
26
32
|
server_config = {
|
27
33
|
:DocumentRoot => document_root,
|
28
34
|
:BindAddress => @config[:address] || ENV['GSS_CONFIG_SERVER_ADDRESS'],
|
@@ -31,19 +37,39 @@ module FontanaClientSupport
|
|
31
37
|
server = WEBrick::HTTPServer.new(server_config)
|
32
38
|
if FontanaClientSupport.root_dir
|
33
39
|
server.mount_proc('/switch_config_server') do |req, res|
|
40
|
+
buf = []
|
34
41
|
unless Dir.exist?(git_dir)
|
35
|
-
|
42
|
+
if git_repo_url = @config[:git_repo_url] || ENV['GSS_CONFIG_SERVER_REPO_URL']
|
43
|
+
Dir.chdir(dir) do
|
44
|
+
cmd = "git clone #{git_repo_url} #{File.basename(git_dir)}"
|
45
|
+
if system(cmd)
|
46
|
+
buf << "SUCCESS: #{cmd}"
|
47
|
+
else
|
48
|
+
buf << "ERROR: #{cmd}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
else
|
52
|
+
FileUtils.cp_r(root_dir, git_dir)
|
53
|
+
buf << "SUCCESS: cp -r #{root_dir} #{git_dir}"
|
54
|
+
end
|
36
55
|
end
|
37
56
|
tag = req.path.sub(%r{\A/switch_config_server/}, '')
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
57
|
+
if tag.nil? || tag.empty?
|
58
|
+
bug << "no tag or SHA1 given"
|
59
|
+
else
|
60
|
+
Dir.chdir(git_dir) do
|
61
|
+
if system("git reset --hard #{tag}")
|
62
|
+
FileUtils.rm_rf(document_root)
|
63
|
+
FileUtils.cp_r(File.join(git_dir, "config_server"), document_root)
|
64
|
+
buf << "SUCCESS"
|
65
|
+
else
|
66
|
+
buf << "ERROR if you use in submodule, set $GSS_CONFIG_SERVER_REPO_URL.\nlike this:\n$ rake config_server:launch GSS_CONFIG_SERVER_PORT=3002 GSS_CONFIG_SERVER_REPO_URL=git@github.com:groovenauts/fontana_sample.git"
|
67
|
+
end
|
68
|
+
end
|
42
69
|
end
|
43
|
-
res.body = Dir["#{document_root}/**/*"].to_a.join("\n ")
|
70
|
+
res.body = (buf + ["", "files: "] + Dir["#{document_root}/**/*"].to_a).join("\n ")
|
44
71
|
end
|
45
72
|
end
|
46
|
-
puts "config_server options: #{@config.inspect}"
|
47
73
|
Signal.trap(:INT){ server.shutdown }
|
48
74
|
server.start
|
49
75
|
end
|