Improve daemon stopping error handling

This commit is contained in:
Arinerron 2018-05-01 23:35:08 -07:00
parent cfb1986ad0
commit 0a7c3aeaab
No known key found for this signature in database
GPG Key ID: 99383627861C62F0
2 changed files with 13 additions and 9 deletions

View File

@ -220,7 +220,7 @@ def error(data, error=None, timestamp=True):
if get_level() <= LEVEL_ERROR:
log('-', data, colors.fg.red, timestamp=timestamp)
if not error is None:
debug('Error details: ' + str(error) + parse_error())
debug('Error: ' + str(error) + parse_error())
# fatal: when the something so bad has happened that the prorgam must stop
def fatal(data, timestamp=True):

View File

@ -527,15 +527,18 @@ class Onionr:
Shutdown the Onionr daemon
'''
logger.warn('Killing the running daemon')
events.event('daemon_stop', onionr = self)
net = NetController(config.get('client')['port'])
logger.warn('Killing the running daemon...', timestamp = False)
try:
self.onionrUtils.localCommand('shutdown')
except requests.exceptions.ConnectionError:
pass
self.onionrCore.daemonQueueAdd('shutdown')
net.killTor()
events.event('daemon_stop', onionr = self)
net = NetController(config.get('client')['port'])
try:
self.onionrUtils.localCommand('shutdown')
except requests.exceptions.ConnectionError:
pass
self.onionrCore.daemonQueueAdd('shutdown')
net.killTor()
except Exception as e:
logger.error('Failed to shutdown daemon.', error = e, timestamp = False)
return
@ -543,6 +546,7 @@ class Onionr:
'''
Displays statistics and exits
'''
logger.info('Our pubkey: ' + self.onionrCore._crypto.pubKey)
logger.info('Our address: ' + self.get_hostname())
return