linecook-gem 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/linecook/provisioner/chef-zero.rb +27 -5
- data/lib/linecook/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab1e346b376c0135f2fcc9b64ebc12b39ec1e3bf
|
4
|
+
data.tar.gz: a1f386fc0fd5a06268b969f4eaa84856eaacbeb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03882e161852a60da0d218b18f6a2afaf4037a4889a9672ece8e113a908b067582dbb1eb128e4ec48c2c40f874ded9c300a59a103fdd8c4076e9a456e066b5ef
|
7
|
+
data.tar.gz: 16a36d542cc4f1a797c13b34ca9a170f12e9a47c15e480e8a84756a4647eaa5d707687dee96d5015bbfbaaf7a11dbf2129942dd00d89cb7f1366163b662428e3
|
@@ -33,6 +33,10 @@ module Linecook
|
|
33
33
|
FileUtils.rm_rf(Cache.path)
|
34
34
|
end
|
35
35
|
|
36
|
+
def chef_port
|
37
|
+
ChefProvisioner::Config.server.split(':')[-1].to_i
|
38
|
+
end
|
39
|
+
|
36
40
|
private
|
37
41
|
|
38
42
|
def setup
|
@@ -42,21 +46,17 @@ module Linecook
|
|
42
46
|
chef_config = config[:chef]
|
43
47
|
chef_config.merge!(node_name: "linecook-#{SecureRandom.hex(4)}",
|
44
48
|
chef_server_url: ChefProvisioner::Config.server)
|
45
|
-
# FIXME: sort out cache copying here for concurrent builds of different refs
|
46
49
|
Chefdepartie.run(background: true, config: chef_config, cache: Cache.path)
|
47
50
|
chef_config
|
48
51
|
end
|
49
52
|
|
50
|
-
def chef_port
|
51
|
-
ChefProvisioner::Config.server.split(':')[-1].to_i
|
52
|
-
end
|
53
|
-
|
54
53
|
# Required in order to have multiple builds run on different refs
|
55
54
|
module Cache
|
56
55
|
CACHE_PATH = File.join(Linecook::Config::LINECOOK_HOME, 'chefcache').freeze
|
57
56
|
PIDFILE = File.join(CACHE_PATH, 'pid')
|
58
57
|
STAMPFILE = File.join(CACHE_PATH, 'stamp')
|
59
58
|
STALE_THRESHOLD = 86400 # one day in seconds
|
59
|
+
WAIT_TIMEOUT = 60 # time to wait for port to become available again
|
60
60
|
|
61
61
|
extend self
|
62
62
|
|
@@ -66,12 +66,34 @@ module Linecook
|
|
66
66
|
cache_path = Dir.mktmpdir('linecook-chef-cache')
|
67
67
|
build
|
68
68
|
copy(cache_path)
|
69
|
+
wait_for_close
|
69
70
|
cache_path
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
73
74
|
private
|
74
75
|
|
76
|
+
def wait_for_close
|
77
|
+
attempts = 0
|
78
|
+
while attempts < WAIT_TIMEOUT
|
79
|
+
begin
|
80
|
+
Timeout::timeout(1) do
|
81
|
+
begin
|
82
|
+
s = TCPSocket.new('127.0.0.1', Linecook::Chef.chef_port)
|
83
|
+
s.close
|
84
|
+
return true
|
85
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
86
|
+
return false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
rescue Timeout::Error
|
90
|
+
puts "Port #{Linecook::Chef.chef_port} is still in use"
|
91
|
+
sleep(1)
|
92
|
+
end
|
93
|
+
attempts += 0
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
75
97
|
def copy(cache_path)
|
76
98
|
FileUtils.copy_entry(CACHE_PATH, cache_path, preserve: true)
|
77
99
|
end
|
data/lib/linecook/version.rb
CHANGED