简体   繁体   English

如何为docker-compose celery命令配置pycharm调试?

[英]How to configure pycharm debug for docker-compose celery command?

I successfully configure my remote interpreter with docker-compose at Pycharm and can successfully run my server in debug mode to put breakpoints and debug the problems. 我在pycharm上使用docker-compose成功配置了远程解释器,并且可以在调试模式下成功运行服务器以放置断点并调试问题。 Unfortunately I can't do the same thing for the docker-compose run for celery workers. 不幸的是,对于芹菜工人来说,我无法对docker-compose运行相同的操作。 When I run this command in my project folder it is working no problem but how can I run this in Pycharm debug mode ? 当我在项目文件夹中运行此命令时,它没有问题,但是如何在Pycharm调试模式下运行此命令?

docker-compose run --rm app celery worker -A workers.build_events -Q build_events -l DEBUG docker-compose run --rm app celery worker -A worker.build_events -Q build_events -l DEBUG

I was just able to get this working with a Python run configuration. 我只是能够使用Python运行配置来实现这一点。

Make sure the working directory is set to the directory that your application code is located at inside your image. 确保将工作目录设置为应用程序代码位于映像内部的目录。

Make sure that the script path is the path to the Celery executable. 确保脚本路径是Celery可执行文件的路径。 In my case, I have a virtualenv inside my application folder, so I just used a relative path from my working directory. 就我而言,我的应用程序文件夹中有一个virtualenv,因此我只使用了工作目录中的相对路径。

Make sure that your interpreter is set to a properly configured docker compose interpreter . 确保将您的解释器设置为正确配置的docker compose解释器

Finally, I've added -P solo to force Celery into a single-threaded mode . 最后,我添加了-P solo以强制Celery进入单线程模式 This is not required, but for me it makes breakpoints and debugging much easier. 这不是必需的,但对我来说,这使断点和调试变得更加容易。

Example run configuration: 运行配置示例: 芹菜运行配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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