RabbitMQ 和 Celery 的新手问题

发布于 2024-12-03 04:09:39 字数 339 浏览 3 评论 0原文

今天早上我开始使用 Celery 和 RabbitMQ 并定义了一些基本任务来看看我的服务器的性能将如何提高。

我已经添加了我的rabbitmq 用户、虚拟主机并设置了我的权限。 启动了我的 RabbitMQ 服务器

在一个非常详细的教程中,我发现这些人使用 celerybeat 和 celeryd 来查看某些任务的状态,并执行它们。

Rich Leland 的详细教程

你是否还需要芹菜,或者我采取的步骤是否足够?

我在任何地方都没有看到任何关于此的信息或注释......只是问

I started playing around with Celery and RabbitMQ this morning and defined some basic tasks to see how the performance will improve on my server.

I have added my rabbitmq user, vhosts and set my permissions.
Started my RabbitMQ server

In a very detailed tutorial I found these guys use celerybeat and celeryd to see the status of some task, and also to execute them.

the detailed tutorial by Rich Leland

Do you also need celery somehow, or are the steps I have taken enough?

Nowhere did I see any info or notes about this... just asking

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青衫儰鉨ミ守葔 2024-12-10 04:09:39

好吧,您需要运行某种 celery 进程才能处理队列中的任务。 celeryd 进程监听队列,并根据您的设置执行任务。如果您没有运行 celeryd 进程,您只需将任务添加到队列中,但永远不会清空它。

如果您只是想查看队列,我建议您安装 RabbitMQ 管理插件

Well, you'll need to have some sort of celery process running in order to handle tasks in the queue. The celeryd process listens on the queue, and executes tasks according to your settings. If you don't have a celeryd process running, you'll just be adding tasks to the queue, but never emptying it.

If you're just interested in seeing your queues, I'd recommend installing the RabbitMQ management plugin.

失与倦" 2024-12-10 04:09:39

http://ask.github.com/celery/getting-started/introduction.html

  1. 启动 RabbitMQ 服务器
  2. 定义 celeryconfig.py
  3. 启动 celery 守护进程:celeryd

RabbitMQ 有访客登录,因此这是一种更快的入门方式。将其放入 celeryconfig.py:

import sys
sys.path.append('.')

BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "guest"
BROKER_VHOST = "/"

CELERY_RESULT_BACKEND = "amqp"

CELERY_IMPORTS = ("tasks",)

为了快速测试,将其放入tasks.py:

from celery.task import task

@task
def add(x, y):
    return x + y

if __name__ == "__main__":
    result = add.delay(4, 4)
    result.wait() 

在同一目录中启动 celeryd 有 celeryconfig.py 和tasks.py:

celeryd --loglevel=INFO

最后,运行tasks.py

http://ask.github.com/celery/getting-started/introduction.html

  1. Start your RabbitMQ server
  2. Define your celeryconfig.py
  3. Start your celery daemon: celeryd

RabbitMQ has a guest login, so that's a faster way to get started. Put this in celeryconfig.py:

import sys
sys.path.append('.')

BROKER_HOST = "localhost"
BROKER_PORT = 5672
BROKER_USER = "guest"
BROKER_PASSWORD = "guest"
BROKER_VHOST = "/"

CELERY_RESULT_BACKEND = "amqp"

CELERY_IMPORTS = ("tasks",)

For a quick test, put this in tasks.py:

from celery.task import task

@task
def add(x, y):
    return x + y

if __name__ == "__main__":
    result = add.delay(4, 4)
    result.wait() 

Start celeryd in the same directory has celeryconfig.py and tasks.py:

celeryd --loglevel=INFO

Finally, run tasks.py

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文