Celery任务功能-Web服务器与远程服务器 [英] Celery tasks functions - web server vs remote server

查看:114
本文介绍了Celery任务功能-Web服务器与远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我愿意将任务从Web服务器(运行Django)发送到装有Rabbitmq服务器以及我用Celery实现的一些工作程序的远程计算机上.

I'm willing to send tasks from a web server (running Django) to a remote machine that is holding a Rabbitmq server and some workers that I implemented with Celery.

如果我遵循Celery的方法,似乎我必须在两台机器之间共享代码,这意味着在Web应用程序代码中复制worker逻辑代码.

If I follow the Celery way to go, it seems I have to share the code between both machines, which means replicating the workers logic code in the web app code.

所以:

  • 是否有这样做的最佳实践?由于代码是冗余的,因此我正在考虑使用git子模块(在Web应用程序代码存储库和工作程序代码存储库中复制的子代)
  • 那我该用芹菜以外的其他东西吗?
  • 我想念什么吗?

推荐答案

管理此问题的一种方法是将您的工作程序存储在django项目中.Django和celery相互配合,可让您在celery应用中使用django项目的一部分. http://celery.readthedocs.org/en/latest/django/first-steps-with-django.html

One way to manage this is to store your workers in your django project. Django and celery play nice to each other allowing you to use parts of your django project in your celery app. http://celery.readthedocs.org/en/latest/django/first-steps-with-django.html

部署此方法意味着您的Web应用程序将不使用与您的celery工人相关的模块,并且在您的celery机器上,您的django视图将永远不会被使用.通常,这只会导致大量未使用的django应用程序代码...

Deploying this would mean that your web application would not use the modules involved with your celery workers, and on your celery machine your django views and such would never be used. This usually only results in a couple of megs of unused django application code...

这篇关于Celery任务功能-Web服务器与远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆