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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 910e83e65e835e4cdadd52ea4832d333e72cb40a
4
- data.tar.gz: 1352fcebf6c527e6c6ec9501d4abca83bf2e5173
2
+ SHA256:
3
+ metadata.gz: 5cfaf35ebfe172724c2abb8d91ac273112eaec29b00cecc9e4885af424ad17e9
4
+ data.tar.gz: 4510246fea3f44312311b80b8029d193599f045c888eaed8721ae6d8b71f2b0e
5
5
  SHA512:
6
- metadata.gz: 7bfb242dd4d8f41a15f590b3d6c5473eac69d040f2b0747791bec31a4377340d1dba695b47d28843e03ed4daf73ffb4a1c5c570d73297e19a85940119ff2d76e
7
- data.tar.gz: 6d2f347ba71ccb9beb24fa6ad580fe876cd9ba49a6ecff3da4794875d83abe21842b344c037bcc0acb0acebb1571fc5f4be1feb7dd1fbbe5cc57f7da73494927
6
+ metadata.gz: fc58f9eca3e31f8ffdb9ecbf52bfea5cfc580c4f2a61f2c5ff148ee301cf9193f563e00cc51160d54616b0ea4af169c8751f821761714ad25bc4d67920851d8c
7
+ data.tar.gz: 8de6d844c4fc9355ed27a483211c0ad93e3e364c88b7497d65598e09dcd19e485cbf2b891ca38a1cf0e703ed2c6e436145cd5f429f8981e9a1a38155a3ad114d
data/Gemfile CHANGED
@@ -8,4 +8,5 @@ gem 'coffee-script'
8
8
  gem 'eco'
9
9
  gem 'uglifier'
10
10
  gem 'nutcracker', ">=0.4.1.20"
11
- gem 'rack', ">= 2.0.6"
11
+ gem "rack", ">= 2.0.8"
12
+ gem 'rake'
@@ -20,9 +20,10 @@ GEM
20
20
  mustermann (1.0.3)
21
21
  nutcracker (0.4.1.22)
22
22
  redis
23
- rack (2.0.6)
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.6)
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.16.1
61
+ 1.17.2
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Nutcracker
2
2
  module Web
3
- VERSION="0.0.15"
3
+ VERSION="0.0.16"
4
4
  end
5
5
  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.15
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: 2018-12-03 00:00:00.000000000 Z
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.6
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.6
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
- rubyforge_project: ruby-nutcracker-web
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