cloud-code-intellij icon indicating copy to clipboard operation
cloud-code-intellij copied to clipboard

PyCharm - Cloud Run Locally not working with gunicorn

Open yan-hic opened this issue 2 years ago • 2 comments

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.

  • IDE type (e.g. IntelliJ, Pycharm): PyCharm
  • IDE version: 2023.3.2 Pro
  • Cloud Code version (Settings > Plugins > Cloud Code): 23.11.3
  • Cloud SDK (Settings > Cloud Code > Cloud SDK)
    • Are you allowing the plugin to manage the Cloud SDK: yes
    • Version of the Cloud SDK: 458.0.1
  • Skaffold version (If you are using Kubernetes features; Settings > Cloud Code > Kubernetes): 2.7.1
  • Operating System: win11

yan-hic avatar Dec 28 '23 23:12 yan-hic

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

ivanporty avatar Jan 04 '24 15:01 ivanporty

@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

briandealwis avatar Jan 08 '24 14:01 briandealwis