Write core launching log messages to file.

This commit is contained in:
tecnovert 2021-12-30 15:25:18 +02:00
parent 86ca94bf70
commit efb0b08ac9
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93

View file

@ -124,30 +124,30 @@ def runClient(fp, data_dir, chain):
for c, v in settings['chainclients'].items(): for c, v in settings['chainclients'].items():
if c == 'monero': if c == 'monero':
if v['manage_daemon'] is True: if v['manage_daemon'] is True:
logger.info('Starting {} daemon'.format(c.capitalize())) swap_client.log.info('Starting {} daemon'.format(c.capitalize()))
daemons.append(startXmrDaemon(v['datadir'], v['bindir'], 'monerod')) daemons.append(startXmrDaemon(v['datadir'], v['bindir'], 'monerod'))
pid = daemons[-1].pid pid = daemons[-1].pid
logger.info('Started {} {}'.format('monerod', pid)) swap_client.log.info('Started {} {}'.format('monerod', pid))
if v['manage_wallet_daemon'] is True: if v['manage_wallet_daemon'] is True:
logger.info('Starting {} wallet daemon'.format(c.capitalize())) swap_client.log.info('Starting {} wallet daemon'.format(c.capitalize()))
daemon_addr = '{}:{}'.format(v['rpchost'], v['rpcport']) daemon_addr = '{}:{}'.format(v['rpchost'], v['rpcport'])
logger.info('daemon-address: {}'.format(daemon_addr)) swap_client.log.info('daemon-address: {}'.format(daemon_addr))
opts = ['--daemon-address', daemon_addr, ] opts = ['--daemon-address', daemon_addr, ]
daemons.append(startXmrWalletDaemon(v['datadir'], v['bindir'], 'monero-wallet-rpc', opts)) daemons.append(startXmrWalletDaemon(v['datadir'], v['bindir'], 'monero-wallet-rpc', opts))
pid = daemons[-1].pid pid = daemons[-1].pid
logger.info('Started {} {}'.format('monero-wallet-rpc', pid)) swap_client.log.info('Started {} {}'.format('monero-wallet-rpc', pid))
continue continue
if v['manage_daemon'] is True: if v['manage_daemon'] is True:
logger.info('Starting {} daemon'.format(c.capitalize())) swap_client.log.info('Starting {} daemon'.format(c.capitalize()))
filename = c + 'd' + ('.exe' if os.name == 'nt' else '') filename = c + 'd' + ('.exe' if os.name == 'nt' else '')
daemons.append(startDaemon(v['datadir'], v['bindir'], filename)) daemons.append(startDaemon(v['datadir'], v['bindir'], filename))
pid = daemons[-1].pid pid = daemons[-1].pid
pids.append((c, pid)) pids.append((c, pid))
swap_client.setDaemonPID(c, pid) swap_client.setDaemonPID(c, pid)
logger.info('Started {} {}'.format(filename, pid)) swap_client.log.info('Started {} {}'.format(filename, pid))
if len(pids) > 0: if len(pids) > 0:
with open(pids_path, 'w') as fd: with open(pids_path, 'w') as fd:
for p in pids: for p in pids:
@ -179,11 +179,11 @@ def runClient(fp, data_dir, chain):
closed_pids = [] closed_pids = []
for d in daemons: for d in daemons:
logging.info('Interrupting {}'.format(d.pid)) swap_client.log.info('Interrupting {}'.format(d.pid))
try: try:
d.send_signal(signal.SIGINT) d.send_signal(signal.SIGINT)
except Exception as e: except Exception as e:
logging.info('Interrupting %d, error %s', d.pid, str(e)) swap_client.log.info('Interrupting %d, error %s', d.pid, str(e))
for d in daemons: for d in daemons:
try: try:
d.wait(timeout=120) d.wait(timeout=120)
@ -192,7 +192,7 @@ def runClient(fp, data_dir, chain):
fp.close() fp.close()
closed_pids.append(d.pid) closed_pids.append(d.pid)
except Exception as ex: except Exception as ex:
logger.error('Error: {}'.format(ex)) swap_client.log.error('Error: {}'.format(ex))
if os.path.exists(pids_path): if os.path.exists(pids_path):
with open(pids_path) as fd: with open(pids_path) as fd: