GoogleCloudPlatform / cloud-code-intellij

Plugin to support the Google Cloud Platform in IntelliJ IDEA - Docs and Issues Repository
Apache License 2.0
318 stars 59 forks source link

PyCharm - Cloud Run Locally not working with gunicorn #3177

Open yan-hic opened 6 months ago

yan-hic commented 6 months ago

When using PyCharm to debug, requirements.txt has unknown dependency on debugpy - and requests is not used either. Likewise, Procfile starts VS Studio debugger - not used with IntelliJ

On the latter, instead of Procfile, why not stay consistent with https://cloud.google.com/run/docs/tips/python#optimize_gunicorn and use a WSGI in Dockerfile CMD since the goal is to deploy to CR eventually. Problem: debugging does not work with gunicorn with Failed to start Cloud Run dev session

For debugging locally, one needs to switch from

CMD gunicorn --preload --bind :8080 --workers 2 --threads 8 --timeout 0 app:app to ENTRYPOINT ["python", "app.py"] Not ideal for change control.

ivanporty commented 6 months ago

Thanks for the report @yan-hic! @briandealwis Do we have any suggestions here Brian?

briandealwis commented 5 months ago

@yan-hic you seen seem to be referencing an example? I'm not sure where this Procfile comes from? Including your logs would be helpful: there are a number of layers involved in enabling debugging (particularly for Python) both on the host PC and the remote cluster, and errors or warnings are emitted during the processing.

Debugging works with gunicorn, and it is used in several of the examples on the skaffold debug page. We don't support unwrapping exec -- trying to parse shell script seemed a recipe for disaster -- though perhaps exec could be worth supporting (I think the relevant code would be here).

Debugging automatically picks up the debugpy through special support images that are made available at run time: the user doesn't need to add debugpy to their requirements.txt. There's some documentation on the skaffold debug doc page.

cc: @renzodavid9 and @ericzzzzzzz from the Skaffold team