34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/tools-cf-plugin/watch.rb', line 34
def watch
app = get_app(input[:app])
host = input[:host]
port = input[:port]
user = input[:user]
pass = input[:password]
subjects = input[:subjects] || [">"]
@requests = {}
@seen_apps = {}
@request_ticker = 0
$stdout.sync = true
watching_nats(
:uri => "nats://#{user}:#{pass}@#{host}:#{port}",
:logs => input[:logs],
:subjects => subjects) do |msg, reply, sub, time|
begin
time ||= Time.now.strftime("%r")
if @requests.include?(sub)
process_response(sub, reply, msg, app, time)
elsif !app || msg.include?(app.guid)
process_message(sub, reply, msg, app, time)
end
rescue => e
line c("couldn't deal w/ #{sub} '#{msg}': #{e.class}: #{e}", :error)
end
end
end
|