nsq-cluster 0.2.5 → 0.2.7
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 +4 -4
- data/lib/nsq-cluster.rb +8 -2
- data/lib/nsq-cluster/process_wrapper.rb +34 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b47dc619bd8a8ea2247893e68b3da23c6303b1f7
|
4
|
+
data.tar.gz: 852cfe562564cd6b793576ee17840e7b0de1e35b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7306f2913bfd847d960f1cab03918ab57a6cdc21a84f6c3adecdac7d2dc59416650c244c21d5e4e77fd42ddc2634bf647b9d503e85fda716d74592adf144f09
|
7
|
+
data.tar.gz: 1f886a10b6cc6a8ecedf32c38b4b196ca9e297cf29e42ddaec22dba1e98d1c90681b1fa531b8bcacbda019e81f8b6e6815b6264f8862520f94adb493a22d3707
|
data/lib/nsq-cluster.rb
CHANGED
@@ -36,8 +36,14 @@ class NsqCluster
|
|
36
36
|
@nsqd = create_nsqds(opts[:nsqd_count], opts[:nsqd_options])
|
37
37
|
@nsqadmin = create_nsqadmin if opts[:nsqadmin]
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
begin
|
40
|
+
# start everything!
|
41
|
+
all_services.each { |d| d.start }
|
42
|
+
rescue Exception => ex
|
43
|
+
# if we hit an error, stop everything that we started
|
44
|
+
destroy
|
45
|
+
raise ex
|
46
|
+
end
|
41
47
|
end
|
42
48
|
|
43
49
|
|
@@ -8,7 +8,7 @@ class ProcessWrapper
|
|
8
8
|
|
9
9
|
|
10
10
|
def start
|
11
|
-
raise "#{command} is already running" if running?
|
11
|
+
raise "#{command} is already running" if running? || another_instance_is_running?
|
12
12
|
@pid = spawn(command, *args, [:out, :err] => output)
|
13
13
|
end
|
14
14
|
|
@@ -31,6 +31,15 @@ class ProcessWrapper
|
|
31
31
|
end
|
32
32
|
|
33
33
|
|
34
|
+
def another_instance_is_running?
|
35
|
+
if respond_to?(:http_port)
|
36
|
+
http_port_open?
|
37
|
+
else
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
34
43
|
def command
|
35
44
|
raise 'you have to override this in a subclass, hotshot'
|
36
45
|
end
|
@@ -52,7 +61,7 @@ class ProcessWrapper
|
|
52
61
|
|
53
62
|
def block_until_running
|
54
63
|
if respond_to?(:http_port) && respond_to?(:host)
|
55
|
-
wait_for_http_port
|
64
|
+
wait_for_http_port
|
56
65
|
else
|
57
66
|
raise "Can't block without http port and host"
|
58
67
|
end
|
@@ -61,7 +70,7 @@ class ProcessWrapper
|
|
61
70
|
|
62
71
|
def block_until_stopped
|
63
72
|
if respond_to?(:http_port) && respond_to?(:host)
|
64
|
-
wait_for_no_http_port
|
73
|
+
wait_for_no_http_port
|
65
74
|
else
|
66
75
|
raise "Can't block without http port and host"
|
67
76
|
end
|
@@ -69,34 +78,33 @@ class ProcessWrapper
|
|
69
78
|
|
70
79
|
|
71
80
|
private
|
72
|
-
def wait_for_http_port
|
73
|
-
|
74
|
-
|
75
|
-
begin
|
76
|
-
response = Net::HTTP.get_response(URI("http://#{host}:#{port}/ping"))
|
77
|
-
if response.is_a?(Net::HTTPSuccess)
|
78
|
-
port_open = true
|
79
|
-
puts "HTTP port #{port} responded to /ping." unless @silent
|
80
|
-
else
|
81
|
-
sleep HTTPCHECK_INTERVAL
|
82
|
-
end
|
83
|
-
rescue Errno::ECONNREFUSED
|
84
|
-
sleep HTTPCHECK_INTERVAL
|
85
|
-
end
|
81
|
+
def wait_for_http_port
|
82
|
+
until http_port_open? do
|
83
|
+
sleep HTTPCHECK_INTERVAL
|
86
84
|
end
|
85
|
+
puts "HTTP port #{http_port} responded to /ping." unless @silent
|
87
86
|
end
|
88
87
|
|
89
88
|
|
90
|
-
def wait_for_no_http_port
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
89
|
+
def wait_for_no_http_port
|
90
|
+
until !http_port_open? do
|
91
|
+
sleep HTTPCHECK_INTERVAL
|
92
|
+
end
|
93
|
+
puts "HTTP port #{http_port} stopped responding to /ping." unless @silent
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
def http_port_open?
|
98
|
+
begin
|
99
|
+
response = Net::HTTP.get_response(URI("http://#{host}:#{http_port}/ping"))
|
100
|
+
if response.is_a?(Net::HTTPSuccess)
|
101
|
+
true
|
102
|
+
else
|
103
|
+
false
|
99
104
|
end
|
105
|
+
rescue Errno::ECONNREFUSED
|
106
|
+
false
|
100
107
|
end
|
101
108
|
end
|
109
|
+
|
102
110
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nsq-cluster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wistia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sys-proctable
|