简体   繁体   中英

GCP cloud-run - Python code does not leave stack-trace when it crashes

I have a strange situation when I deploy a python flask based service on GCP cloud-run.

I have some bug in my code that results in a crash as a part of processing some web API. But GCP cloud-run logs don't show anything except just a 500 error message. The same code, when I deploy locally on my machine throws a proper exception with the line number and other details. How do I get GCP cloud-run logs to show all that? All other logs from my code (other print statements, logger output, etc.) shows reliably. It is just these python exceptions that dont show up - making it impossible to troubleshoot issues that happen in production.

I am attaching an image that shows GCP logger output. You see the 500 error there but nothing about where i my code the exception happened and such.

在此处输入图像描述

Posting this as a community wiki as @sachinsdesai mentioned that the issue occurred when using gunicorn when building and deploying the Cloud Run instance.

In my Dockerfile, I had to replace the first line with the 2nd line for it to work. I still have not found an explanation for it. But I am happy to have made the change - debugging is much easier - especially for long-lived application where one does not always have the luxury to instrument code reproduce problems that happen unexpectedly.

CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 my_main:app

CMD [ "python", "-u", "my_main.py"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM