capistrano-consul_kv_lock 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/capistrano/consul_kv_lock/latch.rb +13 -4
- data/lib/capistrano/consul_kv_lock/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: 054025d77f91b796cce6adc6a0e0c142da62d75b
|
4
|
+
data.tar.gz: 838748f9450e7bfc29dc251b1e2d28620c9d37fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 915ac3ee71d21d003800496b0d2d2723889a8f9f542d792dcf5bc4a90d9d8c07c421d301079028b7122dc5d671a5202920f618c650dc4f56944ca830001232ed
|
7
|
+
data.tar.gz: 4cd3ca73cf866b8f0d1272611a4a05085135a56b8f643162db4bfc90554c857b66708fb6bb2928bcfe6fd3e1dce6263df2410f7511098a01462bde68a28b45b4
|
@@ -16,24 +16,33 @@ module Capistrano
|
|
16
16
|
|
17
17
|
class Latch
|
18
18
|
def self.set_instance(consul_url, options={})
|
19
|
-
@_instance ||=
|
19
|
+
@_instance ||= new(consul_url, options)
|
20
|
+
logger.debug "Registered latch instance: #{@_instance.inspect}"
|
21
|
+
@_instance
|
20
22
|
end
|
21
23
|
|
22
24
|
def self.instance
|
23
25
|
@_instance
|
24
26
|
end
|
25
27
|
|
28
|
+
def self.logger
|
29
|
+
@_logger ||= SSHKittyLogger.new
|
30
|
+
end
|
31
|
+
|
26
32
|
def initialize(consul_url, options={})
|
27
|
-
@logger = SSHKittyLogger.new
|
28
33
|
@client = begin
|
29
34
|
consul = URI.parse(consul_url)
|
30
|
-
Consul::Client.v1.http(host: consul.host, port: consul.port, logger:
|
35
|
+
Consul::Client.v1.http(host: consul.host, port: consul.port, logger: logger)
|
31
36
|
end
|
32
37
|
@lock_key = options[:consul_lock_key] || 'deployment/locked'
|
33
38
|
@session_id = nil
|
34
39
|
end
|
35
40
|
attr_reader :client, :lock_key
|
36
41
|
|
42
|
+
def logger
|
43
|
+
self.class.logger
|
44
|
+
end
|
45
|
+
|
37
46
|
def session_request
|
38
47
|
{
|
39
48
|
"LockDelay" => 15,
|
@@ -54,7 +63,7 @@ module Capistrano
|
|
54
63
|
end
|
55
64
|
|
56
65
|
def create_session
|
57
|
-
|
66
|
+
logger.debug "Session request: #{session_request.inspect}"
|
58
67
|
r = client.put("/session/create", session_request)
|
59
68
|
@session_id = r['ID']
|
60
69
|
end
|