[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 # nginx -t
try: p = subprocess.Popen("nginx -t".split(),
diagnosis['nginx'] = check_output("nginx -t").strip().split("\n") stdout=subprocess.PIPE,
except Exception as e: stderr=subprocess.STDOUT)
import traceback out, _ = p.communicate()
traceback.print_exc() diagnosis["nginx"] = out.strip().split("\n")
logger.warning("Unable to check 'nginx -t', exception: %s" % e) if p.returncode != 0:
logger.error(out)
# Services status # Services status
services = service_status() services = service_status()