M
Marcin Tyman
Hi guys,
Here is piece of my code:
----------------------------------------------------------
def executeAgent()
# establish telnet connection etc.
begin
begin
agent.cmd('String' => "a_command") do |c|
agentLogger.info(c.to_str) #logs to output as well as to
local file
end
rescue TimeoutError => e
#exception handling + logging
end
rescue Errno::ECONNRESET, Errno::ECONNABORTED => e
#exception handling + logging
end
#logging that this function is going to finish because end prompt was
met
end #executeAgent
agentTr = Thread.new do
begin
executeAgent(myLogger)
rescue Exception => e
print("#{__FILE__} #{__LINE__}: executeAgent - #{e}\n")
end
end
while true
#something
puts "agentTr alive" if agentTr.alive?
#something
end
----------------------------------------------------------------
agent.cmd('String' => "a_command") - should never end, so logging to
local file everything what a_command throws should (in theory) never
ends as well (if of course above exceptions wouldn't occur - Timeout,
ECONRESET etc.).
But unfortunately looks like agentTr suddenly evaporates (agentTr.alive?
returns false). Furthermore I've got none of logs from rescues blocks of
code and moreover from the end of executeAgent function. Additionally
I've got none of logs from Thread.new block.
Such situation appears after several hours (randomly)
What is going on? Maybe something is not correct with exceptions
handling or something like that.
If a_command finishes end prompt should be in my logs, if any timeout
occur (in case a_command is suspended) a log should be in logs as well
etc.
I will be appreciated for any help.
Thanks in advance.
MT
Here is piece of my code:
----------------------------------------------------------
def executeAgent()
# establish telnet connection etc.
begin
begin
agent.cmd('String' => "a_command") do |c|
agentLogger.info(c.to_str) #logs to output as well as to
local file
end
rescue TimeoutError => e
#exception handling + logging
end
rescue Errno::ECONNRESET, Errno::ECONNABORTED => e
#exception handling + logging
end
#logging that this function is going to finish because end prompt was
met
end #executeAgent
agentTr = Thread.new do
begin
executeAgent(myLogger)
rescue Exception => e
print("#{__FILE__} #{__LINE__}: executeAgent - #{e}\n")
end
end
while true
#something
puts "agentTr alive" if agentTr.alive?
#something
end
----------------------------------------------------------------
agent.cmd('String' => "a_command") - should never end, so logging to
local file everything what a_command throws should (in theory) never
ends as well (if of course above exceptions wouldn't occur - Timeout,
ECONRESET etc.).
But unfortunately looks like agentTr suddenly evaporates (agentTr.alive?
returns false). Furthermore I've got none of logs from rescues blocks of
code and moreover from the end of executeAgent function. Additionally
I've got none of logs from Thread.new block.
Such situation appears after several hours (randomly)
What is going on? Maybe something is not correct with exceptions
handling or something like that.
If a_command finishes end prompt should be in my logs, if any timeout
occur (in case a_command is suspended) a log should be in logs as well
etc.
I will be appreciated for any help.
Thanks in advance.
MT