0

I am trying to daemonize celery and celerybeat. I have downloaded the celeryd and celeybeat files from github and placed them in /etc/init.d/ (celery and celerybeat) with the corresponding config files under /etc/default/.

My problem is that when I run these two files, celeryd and celerybeat use system python (2.4), and as a result cannot find other installed applications under python 2.7. Python 2.7 is in ~/.bashrc and /.bash_profile files, so I do not have any problems running other applications, except when workers fail to work. When I run python ...../manage.py celery ( with all options) everything works like a charm.

Please let me know how I can force /init.d/function to run python2.7.

I have tried to implement #! /bin/sh python, but it does not work.

4

1 回答 1

0

中的脚本/etc/init.d通常在系统启动时以root身份运行。root 的~/.bashrc(即/root/.bashrc)看起来与您的(例如 )完全不同/home/reza/.bashrc。无论您是否以交互方式运行它,您的 shell 的行为都会略有不同。

因此,尝试通过 运行 python 解释器是没有用的/bin/sh,它只会增加开销。

你想要的是添加一个适当的shebang,告诉系统为你的脚本使用哪个解释器。

例如

#!/usr/bin/python2.7

将使用python2.7安装在/usr/bin. (所以每当你运行/etc/init.d/foo.py系统真的运行/usr/bin/python2.7 /etc/init.d/foo.py

于 2013-07-01T14:17:07.773 回答