1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Adding retry capability to interactWithBroker

This commit is contained in:
Adolfo Gómez García 2016-03-14 09:52:41 +01:00
parent 73bd3cc28e
commit f275a91a43
3 changed files with 25 additions and 6 deletions

View File

@ -87,9 +87,16 @@ class UDSActorSvc(Daemon, CommonService):
set_proctitle('UDSActorDaemon')
# Linux daemon will continue running unless something is requested to
if self.interactWithBroker() is False:
logger.debug('Interact with broker returned false, stopping service after a while')
return
while True:
brokerConnected = self.interactWithBroker()
if brokerConnected is False:
logger.debug('Interact with broker returned false, stopping service after a while')
return
elif brokerConnected is True:
break
# If brokerConnected returns None, repeat the cycle
self.doWait(16000) # Wait for a looong while
if self.isAlive is False:
logger.debug('The service is not alive after broker interaction, stopping it')

View File

@ -127,7 +127,6 @@ class CommonService(object):
return False # On unmanaged hosts, there is no reason right now to continue running
except Exception as e:
logger.debug('Exception on network info: retrying')
logger.exception()
# Any other error is expectable and recoverable, so let's wait a bit and retry again
# but, if too many errors, will log it (one every minute, for
# example)
@ -164,11 +163,11 @@ class CommonService(object):
break
except Exception as e:
logger.error('Error at computer renaming stage: {}'.format(e.message))
return False
return None # Will retry complete broker connection if this point is reached
elif data[0] == 'domain':
if len(params) != 5:
logger.error('Got invalid parameters for domain message: {}'.format(params))
return False
return False # Stop running service
self.joinDomain(params[0], params[1], params[2], params[3], params[4])
break
else:

View File

@ -236,6 +236,19 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService):
# ********************************************************
# * Ask brokers what to do before proceding to main loop *
# ********************************************************
while True:
brokerConnected = self.interactWithBroker()
if brokerConnected is False:
logger.debug('Interact with broker returned false, stopping service after a while')
self.notifyStop()
win32event.WaitForSingleObject(self.hWaitStop, 5000)
return
elif brokerConnected is True:
break
# If brokerConnected returns None, repeat the cycle
self.doWait(16000) # Wait for a looong while
if self.interactWithBroker() is False:
logger.debug('Interact with broker returned false, stopping service after a while')
self.notifyStop()