请原谅,这是我第一次尝试为 centos 5 编写初始化脚本。
我正在使用 django + Supervisor 来管理我的 celery 工作者和调度程序。
现在,这是我天真的简单尝试/etc/init.d/supervisor
#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord
# Source init functions
/home/foo/virtualenv/property_env/bin/python /home/foo/bar/manage.py supervisor --daemonize
在我的supervisor.conf中:
[program:celerybeat]
command=/home/property/virtualenv/property_env/bin/python manage.py celerybeat --loglevel=INFO --logfile=/home/property/property_buyer/logfiles/celerybeat.log
[program:celeryd]
command=/home/foo/virtualenv/property_env/bin/python manage.py celeryd --loglevel=DEBUG --logfile=/home/foo/bar/logfiles/celeryd.log --concurrency=1 -E
[program:celerycam]
command=/home/foo/virtualenv/property_env/bin/python manage.py celerycam
我无法让它工作。
2013-08-06 00:21:03,108 INFO exited: celerybeat (exit status 2; not expected)
2013-08-06 00:21:06,114 INFO spawned: 'celeryd' with pid 11772
2013-08-06 00:21:06,116 INFO spawned: 'celerycam' with pid 11773
2013-08-06 00:21:06,119 INFO spawned: 'celerybeat' with pid 11774
2013-08-06 00:21:06,146 INFO exited: celerycam (exit status 2; not expected)
2013-08-06 00:21:06,147 INFO gave up: celerycam entered FATAL state, too many start retries too quickly
2013-08-06 00:21:06,147 INFO exited: celeryd (exit status 2; not expected)
2013-08-06 00:21:06,152 INFO gave up: celeryd entered FATAL state, too many start retries too quickly
2013-08-06 00:21:06,152 INFO exited: celerybeat (exit status 2; not expected)
2013-08-06 00:21:07,153 INFO gave up: celerybeat entered FATAL state, too many start retries too quickly
我相信这是初始化脚本,但请帮助我了解哪里出了问题。
答案1
有一份文档涵盖了您所需要的全部内容;最好仔细阅读,它位于以下位置:
[alexus@wcmisdlin02 ~]$ ll /usr/share/doc/initscripts-*/
total 92
-rw-r--r--. 1 root root 1996 Oct 10 2013 changes.ipv6
-rw-r--r--. 1 root root 18013 Oct 10 2013 COPYING
-rw-r--r--. 1 root root 5112 Oct 10 2013 ipv6-6to4.howto
-rw-r--r--. 1 root root 2880 Oct 10 2013 ipv6-tunnel.howto
-rw-r--r--. 1 root root 1198 Oct 10 2013 README-init
-rw-r--r--. 1 root root 708 Oct 10 2013 static-routes-ipv6
-rw-r--r--. 1 root root 38931 Oct 10 2013 sysconfig.txt
-rw-r--r--. 1 root root 6357 Oct 10 2013 sysvinitfiles
[alexus@wcmisdlin02 ~]$
但对于初学者来说,似乎至少你缺少start()
一些stop()
子功能(允许你启动或停止服务)。
或者您可以尝试以下操作:用户贡献的 Supervisor 操作系统初始化脚本 -Supervisor/initscripts · GitHub