utils: save log file on failure.

This broke somewhere in the recent changes, because we override
TailalbleProc stop().  Break out log extractor.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-10-03 14:42:01 +10:30 committed by Christian Decker
parent f35e29607d
commit 243fc2c05a
1 changed files with 6 additions and 1 deletions

View File

@ -58,12 +58,15 @@ class TailableProc(object):
self.thread.start()
self.running = True
def stop(self, timeout=10):
def save_log(self):
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 stop(self, timeout=10):
self.save_log()
self.proc.terminate()
# Now give it some time to react to the signal
@ -340,6 +343,8 @@ class LightningNode(object):
if rc is None:
rc = self.daemon.stop()
self.daemon.save_log()
if rc != 0 and not self.may_fail:
raise ValueError("Node did not exit cleanly, rc={}".format(rc))
else: