Output taskd.log to stdout on taskd failures (not test errors)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import division, print_function
|
||||
import os
|
||||
import tempfile
|
||||
import shutil
|
||||
@@ -207,6 +207,8 @@ class Taskd(object):
|
||||
self.proc = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=DEVNULL,
|
||||
env=self.env)
|
||||
else:
|
||||
self.show_log_contents()
|
||||
|
||||
raise OSError("Taskd server is still running or crashed")
|
||||
|
||||
# Wait for server to listen by checking connectivity in the port
|
||||
@@ -218,6 +220,8 @@ class Taskd(object):
|
||||
return
|
||||
|
||||
elif status == self.TASKD_NEVER_STARTED:
|
||||
self.show_log_contents()
|
||||
|
||||
raise OSError("Task server was never started. "
|
||||
"This shouldn't happen!!")
|
||||
|
||||
@@ -225,6 +229,8 @@ class Taskd(object):
|
||||
# Collect output logs
|
||||
out, err = self.proc.communicate()
|
||||
|
||||
self.show_log_contents()
|
||||
|
||||
raise OSError(
|
||||
"Task server launched with '{0}' crashed or exited "
|
||||
"prematurely. Exit code: {1}. "
|
||||
@@ -242,6 +248,8 @@ class Taskd(object):
|
||||
sleep(1 / tries_per_minute)
|
||||
|
||||
else:
|
||||
self.show_log_contents()
|
||||
|
||||
raise OSError("Unknown running status for taskd '{0}'".format(
|
||||
status))
|
||||
|
||||
@@ -251,6 +259,8 @@ class Taskd(object):
|
||||
# Collect output logs
|
||||
out, err = self.proc.communicate()
|
||||
|
||||
self.show_log_contents()
|
||||
|
||||
raise OSError("Task server didn't start and listen on port {0} after "
|
||||
"{1} minutes. Stdout: {2!r}. Stderr: {3!r}.".format(
|
||||
self.port, minutes, out, err))
|
||||
@@ -339,4 +349,14 @@ class Taskd(object):
|
||||
|
||||
return parse_datafile(file)
|
||||
|
||||
def show_log_contents(self):
|
||||
"""Print to to STDOUT the contents of taskd.log
|
||||
"""
|
||||
if os.path.isfile(self.tasklog):
|
||||
with open(self.tasklog) as fh:
|
||||
print("#### Start taskd.log ####")
|
||||
for line in fh:
|
||||
print(line, end='')
|
||||
print("#### End taskd.log ####")
|
||||
|
||||
# vim: ai sts=4 et sw=4
|
||||
|
||||
Reference in New Issue
Block a user