mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
test_lightningd.py: dump logs on error.
I couldn't actually figure out how to just dump them on error, so I dump all the time. When running 3 lightningd + bitcoind, this separates the logs nicely. TODO: We should delete the directories on success! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
39fb7d82fb
commit
2641ecaafa
@ -38,7 +38,7 @@ class TailableProc(object):
|
|||||||
tail the processes and react to their output.
|
tail the processes and react to their output.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, outputDir=None):
|
||||||
self.logs = []
|
self.logs = []
|
||||||
self.logs_cond = threading.Condition(threading.RLock())
|
self.logs_cond = threading.Condition(threading.RLock())
|
||||||
self.thread = threading.Thread(target=self.tail)
|
self.thread = threading.Thread(target=self.tail)
|
||||||
@ -46,6 +46,7 @@ class TailableProc(object):
|
|||||||
self.cmd_line = None
|
self.cmd_line = None
|
||||||
self.running = False
|
self.running = False
|
||||||
self.proc = None
|
self.proc = None
|
||||||
|
self.outputDir = outputDir
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""Start the underlying process and start monitoring it.
|
"""Start the underlying process and start monitoring it.
|
||||||
@ -58,6 +59,11 @@ class TailableProc(object):
|
|||||||
def stop(self):
|
def stop(self):
|
||||||
self.proc.terminate()
|
self.proc.terminate()
|
||||||
self.proc.kill()
|
self.proc.kill()
|
||||||
|
if self.outputDir:
|
||||||
|
logpath = os.path.join(self.outputDir, 'log')
|
||||||
|
with open(logpath, 'w') as f:
|
||||||
|
for l in self.logs:
|
||||||
|
f.write(l + '\n')
|
||||||
|
|
||||||
def tail(self):
|
def tail(self):
|
||||||
"""Tail the stdout of the process and remember it.
|
"""Tail the stdout of the process and remember it.
|
||||||
@ -148,7 +154,7 @@ class SimpleBitcoinProxy:
|
|||||||
class BitcoinD(TailableProc):
|
class BitcoinD(TailableProc):
|
||||||
|
|
||||||
def __init__(self, bitcoin_dir="/tmp/bitcoind-test", rpcport=18332):
|
def __init__(self, bitcoin_dir="/tmp/bitcoind-test", rpcport=18332):
|
||||||
TailableProc.__init__(self)
|
TailableProc.__init__(self, bitcoin_dir)
|
||||||
|
|
||||||
self.bitcoin_dir = bitcoin_dir
|
self.bitcoin_dir = bitcoin_dir
|
||||||
self.rpcport = rpcport
|
self.rpcport = rpcport
|
||||||
@ -183,7 +189,7 @@ class BitcoinD(TailableProc):
|
|||||||
|
|
||||||
class LightningD(TailableProc):
|
class LightningD(TailableProc):
|
||||||
def __init__(self, lightning_dir, bitcoin_dir, port=9735):
|
def __init__(self, lightning_dir, bitcoin_dir, port=9735):
|
||||||
TailableProc.__init__(self)
|
TailableProc.__init__(self, lightning_dir)
|
||||||
self.lightning_dir = lightning_dir
|
self.lightning_dir = lightning_dir
|
||||||
self.port = port
|
self.port = port
|
||||||
self.cmd_line = [
|
self.cmd_line = [
|
||||||
|
Loading…
Reference in New Issue
Block a user