nutcracker-web 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +2 -1
- data/Gemfile.lock +5 -3
- data/lib/nutcracker/web.rb +3 -3
- data/lib/nutcracker/web/app.rb +21 -6
- data/lib/nutcracker/web/version.rb +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5cfaf35ebfe172724c2abb8d91ac273112eaec29b00cecc9e4885af424ad17e9
|
4
|
+
data.tar.gz: 4510246fea3f44312311b80b8029d193599f045c888eaed8721ae6d8b71f2b0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc58f9eca3e31f8ffdb9ecbf52bfea5cfc580c4f2a61f2c5ff148ee301cf9193f563e00cc51160d54616b0ea4af169c8751f821761714ad25bc4d67920851d8c
|
7
|
+
data.tar.gz: 8de6d844c4fc9355ed27a483211c0ad93e3e364c88b7497d65598e09dcd19e485cbf2b891ca38a1cf0e703ed2c6e436145cd5f429f8981e9a1a38155a3ad114d
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -20,9 +20,10 @@ GEM
|
|
20
20
|
mustermann (1.0.3)
|
21
21
|
nutcracker (0.4.1.22)
|
22
22
|
redis
|
23
|
-
rack (2.
|
23
|
+
rack (2.2.2)
|
24
24
|
rack-protection (2.0.4)
|
25
25
|
rack
|
26
|
+
rake (13.0.1)
|
26
27
|
redis (4.0.2)
|
27
28
|
sinatra (2.0.4)
|
28
29
|
mustermann (~> 1.0)
|
@@ -49,11 +50,12 @@ DEPENDENCIES
|
|
49
50
|
eco
|
50
51
|
haml
|
51
52
|
nutcracker (>= 0.4.1.20)
|
52
|
-
rack (>= 2.0.
|
53
|
+
rack (>= 2.0.8)
|
54
|
+
rake
|
53
55
|
sinatra
|
54
56
|
sprockets
|
55
57
|
thin
|
56
58
|
uglifier
|
57
59
|
|
58
60
|
BUNDLED WITH
|
59
|
-
1.
|
61
|
+
1.17.2
|
data/lib/nutcracker/web.rb
CHANGED
@@ -6,7 +6,7 @@ module Nutcracker
|
|
6
6
|
@thread = Thread.new do
|
7
7
|
Thread.current.abort_on_exception=true
|
8
8
|
|
9
|
-
app = Rack::URLMap.new(o.fetch(:context,"/") =>
|
9
|
+
app = Rack::URLMap.new(o.fetch(:context,"/") =>
|
10
10
|
App.new(nutcracker, o.fetch(:external_servers,[])))
|
11
11
|
|
12
12
|
Rack::Server.start(
|
@@ -22,11 +22,11 @@ module Nutcracker
|
|
22
22
|
end
|
23
23
|
self
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def self.join
|
27
27
|
@thread.join
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def self.stop
|
31
31
|
@thread.kill
|
32
32
|
end
|
data/lib/nutcracker/web/app.rb
CHANGED
@@ -4,6 +4,9 @@ require 'tilt/haml'
|
|
4
4
|
require 'haml'
|
5
5
|
require 'sinatra'
|
6
6
|
require 'json'
|
7
|
+
require 'thread'
|
8
|
+
require 'socket'
|
9
|
+
|
7
10
|
|
8
11
|
module Nutcracker
|
9
12
|
module Web
|
@@ -21,11 +24,23 @@ module Nutcracker
|
|
21
24
|
haml :index
|
22
25
|
end
|
23
26
|
|
27
|
+
get '/status' do
|
28
|
+
@nutcracker.
|
29
|
+
config.
|
30
|
+
values.
|
31
|
+
map {|x| x["servers"] + [x["listen"]]}.
|
32
|
+
flatten.
|
33
|
+
map {|x| x.split(":")}.
|
34
|
+
map {|host, port| Thread.new {TCPSocket.new(host,port).close.nil? rescue false}}.map(&:value).
|
35
|
+
all?.
|
36
|
+
tap {|x| status(x ? 200 : 401)}
|
37
|
+
end
|
38
|
+
|
24
39
|
get '/overview.json' do
|
25
40
|
content_type :json
|
26
41
|
overview.to_json
|
27
42
|
end
|
28
|
-
|
43
|
+
|
29
44
|
def self.assets
|
30
45
|
require 'sprockets'
|
31
46
|
Sprockets::Environment.new { |env|
|
@@ -34,18 +49,18 @@ module Nutcracker
|
|
34
49
|
}
|
35
50
|
}
|
36
51
|
end
|
37
|
-
|
52
|
+
|
38
53
|
private
|
39
|
-
|
54
|
+
|
40
55
|
def overview
|
41
56
|
JSON.parse(@nutcracker.overview.to_json).tap do |internal|
|
42
57
|
internal["clusters"] += overview_from_external_servers["clusters"]
|
43
58
|
end
|
44
59
|
end
|
45
|
-
|
60
|
+
|
46
61
|
def overview_from_external_servers
|
47
62
|
{"clusters" => []}.tap do |data|
|
48
|
-
Queue.new.tap do |q|
|
63
|
+
Queue.new.tap do |q|
|
49
64
|
@external_servers.map do |server|
|
50
65
|
Thread.new { q.push JSON.parse(open("http://#{server}/overview.json").read) }
|
51
66
|
end.each(&:join)
|
@@ -53,7 +68,7 @@ module Nutcracker
|
|
53
68
|
end # queue
|
54
69
|
end # data
|
55
70
|
end # def
|
56
|
-
|
71
|
+
|
57
72
|
end
|
58
73
|
end
|
59
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nutcracker-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eran Barak Levi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.0.
|
61
|
+
version: 2.0.8
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.0.
|
68
|
+
version: 2.0.8
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: haml
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
|
-
|
147
|
-
rubygems_version: 2.6.12
|
146
|
+
rubygems_version: 3.0.1
|
148
147
|
signing_key:
|
149
148
|
specification_version: 4
|
150
149
|
summary: Nutcracker Web Interface
|