celery 是否可以在启动时自动运行?

发布于 2024-08-22 11:24:23 字数 440 浏览 5 评论 0原文

我有基于 django 和 celery 的 python 服务器。 每次计算机重新启动时,apache2 都会启动,因此我的服务器正在工作,但我必须手动重新启动 celery(转到我的项目目录并执行“python manage.py celeryd”)。生产的正确解决方案是什么?我的意思是,是否有可能将 celery 作为守护进程启动?

这里 http://github.com/ask/celery/tree /master/contrib/debian/init.d/ 我发现两个脚本看起来应该在 /etc/init.d/ 中,就像启动 apache2 的 apache2 脚本一样。但我把它们放在 /etc/init.d/ 中,我发现没有任何变化。

I have python server based on django and celery.
Each time computer restarts, apache2 starts so my server is working, BUT I have to restart celery manually (going to my project directory and executing "python manage.py celeryd"). What is the correct solution for production? I mean, is there a possibility to start celery as daemon?

Here http://github.com/ask/celery/tree/master/contrib/debian/init.d/ I found two scripts which looks like they should be in /etc/init.d/ like apache2 script that starts apache2. But I put them to /etc/init.d/ and as I see nothing changes.

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

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

发布评论

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

评论(1

不美如何 2024-08-29 11:24:23

你应该看看 http://www.debian-administration.org/article/Making_scripts_run_at_boot_time_with_Debian

简而言之,使用 /etc/init.d 中的 celeryd 脚本:

$ update-rc.d celeryd defaults
Adding system startup for /etc/init.d/celeryd ...
    /etc/rc0.d/K20celeryd -> ../init.d/celeryd
    /etc/rc1.d/K20celeryd -> ../init.d/celeryd
    /etc/rc6.d/K20celeryd -> ../init.d/celeryd
    /etc/rc2.d/S20celeryd -> ../init.d/celeryd
    /etc/rc3.d/S20celeryd -> ../init.d/celeryd
    /etc/rc4.d/S20celeryd -> ../init.d/celeryd
    /etc/rc5.d/S20celeryd -> ../init.d/celeryd

You should take a look at http://www.debian-administration.org/article/Making_scripts_run_at_boot_time_with_Debian

In short, with the celeryd script in /etc/init.d:

$ update-rc.d celeryd defaults
Adding system startup for /etc/init.d/celeryd ...
    /etc/rc0.d/K20celeryd -> ../init.d/celeryd
    /etc/rc1.d/K20celeryd -> ../init.d/celeryd
    /etc/rc6.d/K20celeryd -> ../init.d/celeryd
    /etc/rc2.d/S20celeryd -> ../init.d/celeryd
    /etc/rc3.d/S20celeryd -> ../init.d/celeryd
    /etc/rc4.d/S20celeryd -> ../init.d/celeryd
    /etc/rc5.d/S20celeryd -> ../init.d/celeryd
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文