nsq-cluster 0.2.4 → 0.2.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 +4 -4
- data/bin/nsq-cluster +1 -0
- data/lib/nsq-cluster/nsqadmin.rb +10 -0
- data/lib/nsq-cluster/process_wrapper.rb +25 -0
- data/lib/nsq-cluster.rb +15 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b0210ee2dd176e7c365d50c306c1882a5f93c7b
|
4
|
+
data.tar.gz: 46e60982e791fa040eae65148ba328776c231665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85b1965782495a9c16197da9429545adeeeb74ed6f4109132a0b79a1369fd1863e753edc67ffc3e416875d64fa893dda1bb68708d06b9f528c2be56277ca1e03
|
7
|
+
data.tar.gz: 56927a22f30067f85320cdd988a69cbfd7d368b9910486255ede412c2e0c8c967220553c81fdce43e52f0f56395bb431ee1d496b10176de506e592b1ea0ae25f
|
data/bin/nsq-cluster
CHANGED
data/lib/nsq-cluster/nsqadmin.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'sys/proctable'
|
2
|
+
|
1
3
|
require_relative 'process_wrapper'
|
2
4
|
|
3
5
|
class Nsqadmin < ProcessWrapper
|
@@ -13,6 +15,14 @@ class Nsqadmin < ProcessWrapper
|
|
13
15
|
end
|
14
16
|
|
15
17
|
|
18
|
+
def stop
|
19
|
+
Sys::ProcTable.ps.select{|pe| pe.ppid == @pid}.each do |child_pid|
|
20
|
+
Process.kill('TERM', child_pid)
|
21
|
+
end
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
|
16
26
|
def command
|
17
27
|
'nsqadmin'
|
18
28
|
end
|
@@ -53,6 +53,17 @@ class ProcessWrapper
|
|
53
53
|
def block_until_running
|
54
54
|
if respond_to?(:http_port) && respond_to?(:host)
|
55
55
|
wait_for_http_port(http_port, host)
|
56
|
+
else
|
57
|
+
raise "Can't block without http port and host"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
def block_until_stopped
|
63
|
+
if respond_to?(:http_port) && respond_to?(:host)
|
64
|
+
wait_for_no_http_port(http_port, host)
|
65
|
+
else
|
66
|
+
raise "Can't block without http port and host"
|
56
67
|
end
|
57
68
|
end
|
58
69
|
|
@@ -74,4 +85,18 @@ class ProcessWrapper
|
|
74
85
|
end
|
75
86
|
end
|
76
87
|
end
|
88
|
+
|
89
|
+
|
90
|
+
def wait_for_no_http_port(port, host)
|
91
|
+
port_closed = false
|
92
|
+
until port_closed do
|
93
|
+
begin
|
94
|
+
Net::HTTP.get_response(URI("http://#{host}:#{port}/ping"))
|
95
|
+
sleep HTTPCHECK_INTERVAL
|
96
|
+
rescue Errno::ECONNREFUSED
|
97
|
+
puts "HTTP port #{port} stopped responding to /ping." unless @silent
|
98
|
+
port_closed = true
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
77
102
|
end
|
data/lib/nsq-cluster.rb
CHANGED
@@ -73,7 +73,7 @@ class NsqCluster
|
|
73
73
|
|
74
74
|
|
75
75
|
def destroy
|
76
|
-
|
76
|
+
all_services.each{|s| s.destroy}
|
77
77
|
end
|
78
78
|
|
79
79
|
|
@@ -91,7 +91,20 @@ class NsqCluster
|
|
91
91
|
puts "Cluster launched." unless @silent
|
92
92
|
end
|
93
93
|
rescue Timeout::Error
|
94
|
-
|
94
|
+
raise "Cluster did not fully launch within #{timeout} seconds."
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
def block_until_stopped(timeout = 10)
|
100
|
+
puts "Waiting for cluster to stop..." unless @silent
|
101
|
+
begin
|
102
|
+
Timeout::timeout(timeout) do
|
103
|
+
all_services.each{|service| service.block_until_stopped}
|
104
|
+
puts "Cluster stopped." unless @silent
|
105
|
+
end
|
106
|
+
rescue Timeout::Error
|
107
|
+
raise "Cluster did not fully stop within #{timeout} seconds."
|
95
108
|
end
|
96
109
|
end
|
97
110
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
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.5
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sys-proctable
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: fakeweb
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|