omf_common 6.0.4.pre.1 → 6.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/omf_monitor_topic +6 -0
- data/bin/omf_send_configure +5 -0
- data/bin/omf_send_create +5 -0
- data/bin/omf_send_request +6 -0
- data/lib/omf_common/comm/amqp/amqp_communicator.rb +60 -43
- data/lib/omf_common/exec_app.rb +12 -11
- data/lib/omf_common/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGMxMmVlYjViNTBmOGM2ZmVmZWY5OTNmMDVmNTcyYzJkNjc5OTU5Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGIwZTAwNmI4ZmI3MDE1MzU0ZDQ5ZDM5YmNmOWQ0ZWFhOWQ1YThlOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yzk3YWE4NzllMmQxYTMxZWUxNzZkMzc1YTQ4MzY5ZGY3NWMzOTAzOTlhMDZk
|
10
|
+
M2FjMTkyOGI0YWYyMjk0NWQyOWQ1ODFmZDhlZWNmNWVjNDA0YWUzYmQ0NWFh
|
11
|
+
OTcwMDBjNjM3ZWUyNDU5NzI3ZDk3MDQ1MDM0ZjRlNDJlYjc4OTM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTc1NmQ4ZDA0ZjU4ZmFkMzFkY2QzMTk5OWQ1MWE3ZmJjZDc0YmMxNmUzYjg1
|
14
|
+
MjFkMGZlMWJlNjgwMDJmNWI3OGZjMjNmNDAzYTcxNWM0ZGJlYjAyZTBlYTBl
|
15
|
+
YzIzZGVjMTBiMzUyN2FhMDMxOWJmZDliZDhjNDM0Y2U3NzYxODc=
|
data/bin/omf_monitor_topic
CHANGED
@@ -12,6 +12,12 @@ that there will be a delay until the new monitors are in place which
|
|
12
12
|
can result in missed messages.
|
13
13
|
}
|
14
14
|
|
15
|
+
# The following is to work around a bug in activesupport triggered by
|
16
|
+
# the JWT library which is used only in the AMQP transport, os it
|
17
|
+
# fails quietly if that library is not installed in XMPP deployments
|
18
|
+
begin; require 'json/jwt'; rescue Exception; end
|
19
|
+
|
20
|
+
|
15
21
|
require 'optparse'
|
16
22
|
require 'omf_common'
|
17
23
|
|
data/bin/omf_send_configure
CHANGED
@@ -10,6 +10,11 @@ Any additional command line arguments are interpreted as property:value and are
|
|
10
10
|
sent with the create message.
|
11
11
|
}
|
12
12
|
|
13
|
+
# The following is to work around a bug in activesupport triggered by
|
14
|
+
# the JWT library which is used only in the AMQP transport, os it
|
15
|
+
# fails quietly if that library is not installed in XMPP deployments
|
16
|
+
begin; require 'json/jwt'; rescue Exception; end
|
17
|
+
|
13
18
|
require 'omf_common'
|
14
19
|
|
15
20
|
OP_MODE = :development
|
data/bin/omf_send_create
CHANGED
@@ -10,6 +10,11 @@ Any additional command line arguments are interpreted as property:value and are
|
|
10
10
|
sent with the create message.
|
11
11
|
}
|
12
12
|
|
13
|
+
# The following is to work around a bug in activesupport triggered by
|
14
|
+
# the JWT library which is used only in the AMQP transport, os it
|
15
|
+
# fails quietly if that library is not installed in XMPP deployments
|
16
|
+
begin; require 'json/jwt'; rescue Exception; end
|
17
|
+
|
13
18
|
require 'omf_common'
|
14
19
|
|
15
20
|
OP_MODE = :development
|
data/bin/omf_send_request
CHANGED
@@ -10,6 +10,12 @@ Any additional command line arguments are interpreted as limiting the request
|
|
10
10
|
to those, otherwise all properties are requested.
|
11
11
|
}
|
12
12
|
|
13
|
+
# The following is to work around a bug in activesupport triggered by
|
14
|
+
# the JWT library which is used only in the AMQP transport, os it
|
15
|
+
# fails quietly if that library is not installed in XMPP deployments
|
16
|
+
begin; require 'json/jwt'; rescue Exception; end
|
17
|
+
|
18
|
+
|
13
19
|
require 'omf_common'
|
14
20
|
|
15
21
|
OP_MODE = :development
|
@@ -34,7 +34,6 @@ module OmfCommon
|
|
34
34
|
end
|
35
35
|
@address_prefix = @url + '/'
|
36
36
|
_connect()
|
37
|
-
#AMQP::Session#on_skipped_heartbeats callback that can be used to handle skipped heartbeats
|
38
37
|
super
|
39
38
|
end
|
40
39
|
|
@@ -119,60 +118,78 @@ module OmfCommon
|
|
119
118
|
end
|
120
119
|
|
121
120
|
def _connect()
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
121
|
+
begin
|
122
|
+
last_reported_timestamp = nil
|
123
|
+
@session = ::AMQP.connect(@url, @opts) do |connection|
|
124
|
+
connection.on_tcp_connection_loss do |conn, settings|
|
125
|
+
now = Time.now
|
126
|
+
if last_reported_timestamp == nil || (now - last_reported_timestamp) > 60
|
127
|
+
warn "Lost connectivity. Trying to reconnect..."
|
128
|
+
last_reported_timestamp = now
|
129
|
+
end
|
130
|
+
_reconnect(conn)
|
129
131
|
end
|
130
|
-
|
131
|
-
|
132
|
-
@channel = ::AMQP::Channel.new(connection)
|
133
|
-
@channel.auto_recovery = true
|
132
|
+
@channel = ::AMQP::Channel.new(connection)
|
133
|
+
@channel.auto_recovery = true
|
134
134
|
|
135
|
+
@on_connected_procs.each do |proc|
|
136
|
+
proc.arity == 1 ? proc.call(self) : proc.call
|
137
|
+
end
|
135
138
|
|
136
|
-
|
137
|
-
|
139
|
+
OmfCommon.eventloop.on_stop do
|
140
|
+
connection.close
|
141
|
+
end
|
138
142
|
end
|
139
143
|
|
140
|
-
|
141
|
-
|
144
|
+
rec_delay = @opts[:reconnect_delay]
|
145
|
+
@session.on_tcp_connection_failure do
|
146
|
+
warn "Cannot connect to AMQP server '#{@url}'. Attempt to retry in #{rec_delay} sec"
|
147
|
+
@session = nil
|
148
|
+
OmfCommon.eventloop.after(rec_delay) do
|
149
|
+
info 'Retrying'
|
150
|
+
_connect
|
151
|
+
end
|
142
152
|
end
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
OmfCommon.eventloop.after(rec_delay) do
|
150
|
-
info 'Retrying'
|
151
|
-
_connect
|
153
|
+
# @session.on_tcp_connection_loss do
|
154
|
+
# _reconnect "Appear to have lost tcp connection. Attempt to reconnect in #{rec_delay} sec"
|
155
|
+
# end
|
156
|
+
@session.on_skipped_heartbeats do
|
157
|
+
info '... on_skipped_heartbeats!'
|
158
|
+
#_reconnect "Appear to have lost heartbeat. Attempt to reconnect in #{rec_delay} sec"
|
152
159
|
end
|
160
|
+
@session.on_recovery do
|
161
|
+
info 'Recovered!'
|
162
|
+
last_reported_timestamp = nil
|
163
|
+
@on_reconnect.values.each do |block|
|
164
|
+
block.call()
|
165
|
+
end
|
166
|
+
end
|
167
|
+
true
|
168
|
+
rescue Exception => ex
|
169
|
+
delay = @opts[:reconnect_delay]
|
170
|
+
warn "Connecting AMQP failed, will retry in #{delay} (#{ex})"
|
171
|
+
OmfCommon.eventloop.after(delay) do
|
172
|
+
if _connect
|
173
|
+
info 'Reconnection suceeded'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
false
|
153
177
|
end
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
178
|
+
end
|
179
|
+
|
180
|
+
def _reconnect(conn)
|
181
|
+
begin
|
182
|
+
conn.reconnect(false, 2)
|
183
|
+
rescue Exception => ex
|
184
|
+
delay = @opts[:reconnect_delay]
|
185
|
+
warn "Reconnect AMQP failed, will retry in #{delay} (#{ex})"
|
186
|
+
OmfCommon.eventloop.after(delay) do
|
187
|
+
info 'Reconnecting'
|
188
|
+
_reconnect(conn)
|
165
189
|
end
|
166
190
|
end
|
167
191
|
end
|
168
192
|
|
169
|
-
# def _reconnect(warn_message = nil)
|
170
|
-
# warn(warn_message) if warn_message
|
171
|
-
# OmfCommon.eventloop.after(@opts[:reconnect_delay]) do
|
172
|
-
# info 'Reconnecting'
|
173
|
-
# @session.reconnect
|
174
|
-
# end
|
175
|
-
# end
|
176
193
|
end
|
177
194
|
end
|
178
195
|
end
|
data/lib/omf_common/exec_app.rb
CHANGED
@@ -37,7 +37,7 @@ require 'fcntl'
|
|
37
37
|
# Borrows from Open3
|
38
38
|
#
|
39
39
|
class ExecApp
|
40
|
-
|
40
|
+
|
41
41
|
# Holds the pids for all active apps
|
42
42
|
@@all_apps = Hash.new
|
43
43
|
|
@@ -55,7 +55,7 @@ class ExecApp
|
|
55
55
|
end
|
56
56
|
|
57
57
|
attr_reader :pid, :clean_exit
|
58
|
-
|
58
|
+
|
59
59
|
# True if this active app is being killed by a proper
|
60
60
|
# call to ExecApp.signal_all() or signal()
|
61
61
|
# (i.e. when the caller of ExecApp decided to stop the application,
|
@@ -70,11 +70,11 @@ class ExecApp
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def signal(signal = 'KILL')
|
73
|
+
logger.debug "Sending signal '#{signal}' to app '#{@id}' with pid #{@pid}"
|
73
74
|
@clean_exit = true
|
74
75
|
Process.kill(signal, -1 * @pid) # we are sending to the entire process group
|
75
76
|
end
|
76
77
|
|
77
|
-
|
78
78
|
#
|
79
79
|
# Run an application 'cmd' in a separate thread and monitor
|
80
80
|
# its stdout. Also send status reports to the 'observer' by
|
@@ -115,9 +115,9 @@ class ExecApp
|
|
115
115
|
pe[1].close
|
116
116
|
|
117
117
|
begin
|
118
|
-
pgid = Process.setsid # Create a new process group
|
118
|
+
pgid = Process.setsid # Create a new process group
|
119
119
|
# which includes all potential child processes
|
120
|
-
STDOUT.puts "INTERNAL WARNING: Assuming process_group_id == pid" unless pgid == $$
|
120
|
+
STDOUT.puts "INTERNAL WARNING: Assuming process_group_id == pid" unless pgid == $$
|
121
121
|
Dir.chdir working_directory if working_directory
|
122
122
|
exec(cmd)
|
123
123
|
rescue => ex
|
@@ -135,9 +135,10 @@ class ExecApp
|
|
135
135
|
monitor_pipe(map_std_err_to_out ? :stdout : :stderr, pe[0])
|
136
136
|
# Create thread which waits for application to exit
|
137
137
|
@threads << Thread.new(id, @pid) do |id, pid|
|
138
|
-
|
139
|
-
|
140
|
-
|
138
|
+
Process.waitpid(pid)
|
139
|
+
# Exit status is sometimes nil (OSX 10.8, ping)
|
140
|
+
@exit_status = $?.exitstatus || 0
|
141
|
+
if @exit_status > 127
|
141
142
|
@exit_status = 128 - @exit_status
|
142
143
|
end
|
143
144
|
@@all_apps.delete(@id)
|
@@ -149,7 +150,7 @@ class ExecApp
|
|
149
150
|
end
|
150
151
|
end
|
151
152
|
@stdin = pw[1]
|
152
|
-
|
153
|
+
|
153
154
|
# wait for done in yet another thread
|
154
155
|
Thread.new do
|
155
156
|
@threads.each {|t| t.join }
|
@@ -157,7 +158,7 @@ class ExecApp
|
|
157
158
|
end
|
158
159
|
logger.debug "Application is running with PID #{@pid}"
|
159
160
|
end
|
160
|
-
|
161
|
+
|
161
162
|
private
|
162
163
|
|
163
164
|
#
|
@@ -184,7 +185,7 @@ class ExecApp
|
|
184
185
|
end
|
185
186
|
end
|
186
187
|
end
|
187
|
-
|
188
|
+
|
188
189
|
def call_observer(event_type, msg)
|
189
190
|
return unless @observer
|
190
191
|
begin
|
data/lib/omf_common/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omf_common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.4
|
4
|
+
version: 6.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NICTA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -263,9 +263,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
263
263
|
version: 1.9.3
|
264
264
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
265
265
|
requirements:
|
266
|
-
- - ! '
|
266
|
+
- - ! '>='
|
267
267
|
- !ruby/object:Gem::Version
|
268
|
-
version:
|
268
|
+
version: '0'
|
269
269
|
requirements: []
|
270
270
|
rubyforge_project: omf_common
|
271
271
|
rubygems_version: 2.0.7
|