tail-cf-plugin 0.0.13.pre → 0.0.14.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tail-cf-plugin/loggregator_client.rb +22 -25
- data/lib/tail-cf-plugin/plugin.rb +7 -4
- metadata +82 -2
@@ -1,35 +1,32 @@
|
|
1
|
+
require 'celluloid/websocket/client'
|
2
|
+
|
1
3
|
module TailCfPlugin
|
2
4
|
class LoggregatorClient
|
5
|
+
include Celluloid
|
6
|
+
|
3
7
|
def initialize(output)
|
4
8
|
@output = output
|
5
9
|
end
|
6
10
|
|
7
11
|
def listen(loggregator_host, space_id, app_id, user_token)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
output.puts
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
received_message = LogMessage.decode(chunk)
|
27
|
-
output.puts([received_message.app_id, received_message.source_id, received_message.message_type_name, received_message.message].join(" "))
|
28
|
-
end
|
29
|
-
else
|
30
|
-
output.puts("Error #{response.code}: #{response.body}")
|
31
|
-
end
|
32
|
-
end
|
12
|
+
websocket_address = "ws://#{loggregator_host}/tail/spaces/#{space_id}"
|
13
|
+
websocket_address += "/apps/#{app_id}" if app_id
|
14
|
+
websocket_address += "?authorization=#{URI.encode(user_token)}"
|
15
|
+
|
16
|
+
@client = Celluloid::WebSocket::Client.new(websocket_address, current_actor, headers: {"Origin" => "http://localhost" })
|
17
|
+
end
|
18
|
+
|
19
|
+
def on_open
|
20
|
+
output.puts("Connected to server.")
|
21
|
+
end
|
22
|
+
|
23
|
+
def on_message(data)
|
24
|
+
received_message = LogMessage.decode(data.pack("C*"))
|
25
|
+
output.puts([received_message.app_id, received_message.source_id, received_message.message_type_name, received_message.message].join(" "))
|
26
|
+
end
|
27
|
+
|
28
|
+
def on_close(code, reason)
|
29
|
+
output.puts("Server dropped connection...goodbye. #{code} #{reason}")
|
33
30
|
end
|
34
31
|
|
35
32
|
private
|
@@ -3,7 +3,6 @@ require 'cf'
|
|
3
3
|
module TailCfPlugin
|
4
4
|
require 'tail-cf-plugin/loggregator_client'
|
5
5
|
require 'log_message/log_message.pb'
|
6
|
-
require 'uri'
|
7
6
|
|
8
7
|
class Plugin < CF::CLI
|
9
8
|
include LoginRequirements
|
@@ -26,6 +25,7 @@ module TailCfPlugin
|
|
26
25
|
|
27
26
|
loggregator_client = LoggregatorClient.new(STDOUT)
|
28
27
|
loggregator_client.listen(loggregator_host, client.current_space.guid, app_guid, client.token.auth_header)
|
28
|
+
wait_for_ws_connection_close
|
29
29
|
end
|
30
30
|
|
31
31
|
::ManifestsPlugin.default_to_app_from_manifest(:tail, false)
|
@@ -33,9 +33,12 @@ module TailCfPlugin
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def loggregator_host
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
target_base = client.target.sub(/^https?:\/\/([^\.]+\.)?(.+)\/?/, '\2')
|
37
|
+
"loggregator.#{target_base}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def wait_for_ws_connection_close
|
41
|
+
sleep
|
39
42
|
end
|
40
43
|
|
41
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tail-cf-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14.pre
|
5
5
|
prerelease: 7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cf
|
@@ -49,6 +49,86 @@ dependencies:
|
|
49
49
|
- - ~>
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: 0.3.7
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: celluloid-websocket-client
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.0.1
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.0.1
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: rake
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: thin
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
type: :development
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: faye-websocket
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
52
132
|
description: CF command line tool to tail CF Application Logs
|
53
133
|
email:
|
54
134
|
- vcap-dev@googlegroups.com
|