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:
parent
73bd3cc28e
commit
f275a91a43
@ -87,9 +87,16 @@ class UDSActorSvc(Daemon, CommonService):
|
|||||||
set_proctitle('UDSActorDaemon')
|
set_proctitle('UDSActorDaemon')
|
||||||
|
|
||||||
# Linux daemon will continue running unless something is requested to
|
# Linux daemon will continue running unless something is requested to
|
||||||
if self.interactWithBroker() is False:
|
while True:
|
||||||
|
brokerConnected = self.interactWithBroker()
|
||||||
|
if brokerConnected is False:
|
||||||
logger.debug('Interact with broker returned false, stopping service after a while')
|
logger.debug('Interact with broker returned false, stopping service after a while')
|
||||||
return
|
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:
|
if self.isAlive is False:
|
||||||
logger.debug('The service is not alive after broker interaction, stopping it')
|
logger.debug('The service is not alive after broker interaction, stopping it')
|
||||||
|
@ -127,7 +127,6 @@ class CommonService(object):
|
|||||||
return False # On unmanaged hosts, there is no reason right now to continue running
|
return False # On unmanaged hosts, there is no reason right now to continue running
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug('Exception on network info: retrying')
|
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
|
# 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
|
# but, if too many errors, will log it (one every minute, for
|
||||||
# example)
|
# example)
|
||||||
@ -164,11 +163,11 @@ class CommonService(object):
|
|||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error('Error at computer renaming stage: {}'.format(e.message))
|
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':
|
elif data[0] == 'domain':
|
||||||
if len(params) != 5:
|
if len(params) != 5:
|
||||||
logger.error('Got invalid parameters for domain message: {}'.format(params))
|
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])
|
self.joinDomain(params[0], params[1], params[2], params[3], params[4])
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -236,6 +236,19 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService):
|
|||||||
# ********************************************************
|
# ********************************************************
|
||||||
# * Ask brokers what to do before proceding to main loop *
|
# * 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:
|
if self.interactWithBroker() is False:
|
||||||
logger.debug('Interact with broker returned false, stopping service after a while')
|
logger.debug('Interact with broker returned false, stopping service after a while')
|
||||||
self.notifyStop()
|
self.notifyStop()
|
||||||
|
Loading…
Reference in New Issue
Block a user