[fix] nginx diagnosis when there's an error throwing a huge useless traceback. Use Popen instead to display the real error

This commit is contained in:
Alexandre Aubin 2019-04-03 13:02:15 +02:00
parent bf3ffc3e7d
commit 5c4bf1ed29

View file

@ -720,12 +720,13 @@ def tools_diagnosis(auth, private=False):
}
# nginx -t
try:
diagnosis['nginx'] = check_output("nginx -t").strip().split("\n")
except Exception as e:
import traceback
traceback.print_exc()
logger.warning("Unable to check 'nginx -t', exception: %s" % e)
p = subprocess.Popen("nginx -t".split(),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
out, _ = p.communicate()
diagnosis["nginx"] = out.strip().split("\n")
if p.returncode != 0:
logger.error(out)
# Services status
services = service_status()