goat 0.3.19 → 0.3.21
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/channel-srv +24 -2
- data/bin/state-srv +7 -1
- data/goat.gemspec +1 -1
- data/lib/goat/state-srv.rb +9 -3
- metadata +4 -4
data/bin/channel-srv
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'eventmachine'
|
5
5
|
require 'json'
|
6
|
+
require 'optparse'
|
6
7
|
require 'thin'
|
7
8
|
require 'rack'
|
8
9
|
|
@@ -141,6 +142,27 @@ module Goat
|
|
141
142
|
end
|
142
143
|
end
|
143
144
|
|
145
|
+
$host = '0.0.0.0'
|
146
|
+
$port = 8050
|
147
|
+
|
148
|
+
$statesrv_host = '127.0.0.1'
|
149
|
+
$statesrv_port = 8011
|
150
|
+
|
151
|
+
def usage
|
152
|
+
$stderr.puts <<-EOH
|
153
|
+
#{__FILE__} [-p port] [-H host] [-s statesrv_port] [-S statesrv_host]
|
154
|
+
EOH
|
155
|
+
end
|
156
|
+
|
157
|
+
OptionParser.new do |opts|
|
158
|
+
opts.on('-pMANDATORY', Integer) {|p| $port = r}
|
159
|
+
opts.on('-HMANDATORY', String) {|h| $host = h}
|
160
|
+
opts.on('-SMANDATORY', String) {|h| $statesrv_host = h}
|
161
|
+
opts.on('-sMANDATORY', Integer) {|p| $statesrv_port = p}
|
162
|
+
opts.on('-v') {} # suppress optparse wanting to use -v as version
|
163
|
+
opts.on('-h') {usage; exit 1}
|
164
|
+
end.parse!(ARGV)
|
165
|
+
|
144
166
|
app = Rack::Builder.app do |builder|
|
145
167
|
use Rack::CommonLogger
|
146
168
|
use Rack::ShowExceptions
|
@@ -149,6 +171,6 @@ end
|
|
149
171
|
|
150
172
|
Goat.announce_launch('channel-srv')
|
151
173
|
EM.run do
|
152
|
-
Goat::ChannelSrv::ChannelStateConnection.connect
|
153
|
-
Rack::Handler::Thin.run(app, :
|
174
|
+
Goat::ChannelSrv::ChannelStateConnection.connect($statesrv_host, $statesrv_port)
|
175
|
+
Rack::Handler::Thin.run(app, :Host => $host, :Port => $port)
|
154
176
|
end
|
data/bin/state-srv
CHANGED
@@ -344,7 +344,7 @@ module Goat
|
|
344
344
|
|
345
345
|
def run
|
346
346
|
@registry.connected_pages.each do |pgid|
|
347
|
-
if @registry.last_connected_delta(pgid) >
|
347
|
+
if @registry.last_connected_delta(pgid) > (60 * 60)
|
348
348
|
Goat.logd "Deleting page #{pgid}"
|
349
349
|
@registry.delete_page(pgid)
|
350
350
|
end
|
@@ -401,6 +401,12 @@ end
|
|
401
401
|
$host = '127.0.0.1'
|
402
402
|
$port = 8011
|
403
403
|
|
404
|
+
def usage
|
405
|
+
$stderr.puts <<-EOH
|
406
|
+
#{__FILE__} [-p port] [-H host]
|
407
|
+
EOH
|
408
|
+
end
|
409
|
+
|
404
410
|
OptionParser.new do |opts|
|
405
411
|
# this is the second jankiest optparser I've ever used
|
406
412
|
opts.on('-pMANDATORY', Integer) {|r| $port = r}
|
data/goat.gemspec
CHANGED
data/lib/goat/state-srv.rb
CHANGED
@@ -2,7 +2,8 @@ module Goat
|
|
2
2
|
module StateSrvClient
|
3
3
|
def self.configure(opts={})
|
4
4
|
# TODO implement fully
|
5
|
-
EM.next_tick { StateSrvConnection.connect
|
5
|
+
EM.next_tick { StateSrvConnection.connect(opts[:host] || '127.0.0.1',
|
6
|
+
opts[:port] || 8011) }
|
6
7
|
end
|
7
8
|
|
8
9
|
def self.send_message(type, m, sync=false)
|
@@ -46,12 +47,17 @@ module Goat
|
|
46
47
|
def self.connection=(c); @@connection = c; end
|
47
48
|
def self.connected?; @@connection != nil; end
|
48
49
|
|
49
|
-
def self.connect(host
|
50
|
+
def self.connect(host, port, &dlg)
|
50
51
|
@host = host
|
51
52
|
@port = port
|
52
53
|
EM.connect(host, port, self)
|
53
54
|
end
|
54
55
|
|
56
|
+
def self.reconnect
|
57
|
+
raise 'Reconnect called before connection made' if @host.nil? || @port.nil?
|
58
|
+
self.connect(@host, @port)
|
59
|
+
end
|
60
|
+
|
55
61
|
def self.send_message_sync(msg)
|
56
62
|
s = TCPSocket.open(@host, @port)
|
57
63
|
s.write(msg.to_json + "\n")
|
@@ -113,7 +119,7 @@ module Goat
|
|
113
119
|
end
|
114
120
|
|
115
121
|
StateSrvConnection.connection = nil
|
116
|
-
EM.add_timer(5) { self.class.
|
122
|
+
EM.add_timer(5) { self.class.reconnect }
|
117
123
|
end
|
118
124
|
end
|
119
125
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 21
|
10
|
+
version: 0.3.21
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Patrick Collison
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-08 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|