为什么主管总是让 celery worker 改变形式 运行 开始?
Why the supervisor make the celery worker changing form running to starting all the time?
背景
系统是Centos7,里面有个python2.x。 1GB 内存和单核。
我安装 python3.x ,我可以将 python3 编码为 python3.
django-celery 项目基于 virtualenv python3.x,我在 nginx、uwsgi、mariadb 上做得很好。至少,我是这么认为的,没有发生错误。
我尝试使用 supervisor 来控制 django-celery 的 worker,如下所示:
command=env/bin/python project/manage.py celeryd -l INFO -n worker_%(process_num)s
numprocs=4
process_name=projects_worker_%(process_num)s
stdout_logfile=logfile.log
etderr_logfile=logfile_err.log
也做了celery事件的设置,celery beat,这部分很好,没有报错。错误来自工作人员。
当我保持进程大于1时,一开始会运行,当我做supervisorctl status
时,都是运行ning。
但是当我再次执行相同的命令查看状态时,一些进程状态变为正在启动。
所以我多试了几次,发现that:the worker的状态总是从运行开始,然后变成运行ning--没有停止。
当我在 tmp/supervisor.log 查看主管的日志文件时,它显示如下:
exit status 1; not expected
entered runnging state,process has stayed up for > than 1 seconds(startsecs)
'project_worker_0' with pid 2284
也许这说明了为什么工人一直在改变状态。
更重要的是,当我将过程更改为 1 时,worker 可以 failed.The worker 的日志显示:
stale pidfile exists.Removing it
但是,我没有将 pidfile 路径指向 worker.And,我只是在 /
路径找到了 events 和 beat 的 pidfie,没有工人的 pidfile.Also,我试试find / -name *.pid
找到类似 worker 或 celeryd 的 pid 文件,但这里不存在。
问题
首先,我想部署这个项目,那么,这里有没有其他方法来部署 django-celery 和 virtulanev 的 celery 部分?
如果这里有人能告诉我这个现象是怎么来的,我最好选择supervisor来部署celery部分。任何人都可以帮助我吗?
PS
您的任何想法都可能对我有所帮助,祝您好运!
终于在昨天晚上解决了这个问题
关于原因
我在windows10的系统上让项目可以成功运行ning,但是当我把项目改成centos7.+时没有检查。命令:env/bin/python project/manage.py celeryd
无法运行成功。所以主管会启动一个很快就会失败的进程。
为什么命令无法成功?我已经 pip 安装了所有需要的包。但是下面显示错误:
Running a worker with superuser privileges when the worker accepts messages serialized with pickle is a very bad idea!
If you really want to continue then you have to set the C_FORCE_ROOT
environment variable (but please think about this before you do).
User information: uid=0 euid=0 gid=0 egid=0
我试着搜索一些关于这个错误的博客,得到答案:
export C_FORCE_ROOT='true' # at the centos enviroument
要解决的措施(遇到这样的错误后)
将export C_FORCE_ROOT='true'
添加到centos的环境文件中并获取它。
检查命令'env/bin/python project/manage.py celeryd ',是否运行成功。
重启supervisord。请注意!不是 supervisorctl reload
,它只是重新加载 .conf 文件,而不是环境文件。尝试终止进程 supervisord -c xx.conf
(ps aux | grep supervisord
和 kill -9 process_number
,小心)。
关于博客的一些 url
背景
系统是Centos7,里面有个python2.x。 1GB 内存和单核。
我安装 python3.x ,我可以将 python3 编码为 python3.
django-celery 项目基于 virtualenv python3.x,我在 nginx、uwsgi、mariadb 上做得很好。至少,我是这么认为的,没有发生错误。
我尝试使用 supervisor 来控制 django-celery 的 worker,如下所示:
command=env/bin/python project/manage.py celeryd -l INFO -n worker_%(process_num)s
numprocs=4
process_name=projects_worker_%(process_num)s
stdout_logfile=logfile.log
etderr_logfile=logfile_err.log
也做了celery事件的设置,celery beat,这部分很好,没有报错。错误来自工作人员。
当我保持进程大于1时,一开始会运行,当我做supervisorctl status
时,都是运行ning。
但是当我再次执行相同的命令查看状态时,一些进程状态变为正在启动。
所以我多试了几次,发现that:the worker的状态总是从运行开始,然后变成运行ning--没有停止。
当我在 tmp/supervisor.log 查看主管的日志文件时,它显示如下:
exit status 1; not expected
entered runnging state,process has stayed up for > than 1 seconds(startsecs)
'project_worker_0' with pid 2284
也许这说明了为什么工人一直在改变状态。
更重要的是,当我将过程更改为 1 时,worker 可以 failed.The worker 的日志显示:
stale pidfile exists.Removing it
但是,我没有将 pidfile 路径指向 worker.And,我只是在 /
路径找到了 events 和 beat 的 pidfie,没有工人的 pidfile.Also,我试试find / -name *.pid
找到类似 worker 或 celeryd 的 pid 文件,但这里不存在。
问题
首先,我想部署这个项目,那么,这里有没有其他方法来部署 django-celery 和 virtulanev 的 celery 部分?
如果这里有人能告诉我这个现象是怎么来的,我最好选择supervisor来部署celery部分。任何人都可以帮助我吗?
PS
您的任何想法都可能对我有所帮助,祝您好运!
终于在昨天晚上解决了这个问题
关于原因
我在windows10的系统上让项目可以成功运行ning,但是当我把项目改成centos7.+时没有检查。命令:
env/bin/python project/manage.py celeryd
无法运行成功。所以主管会启动一个很快就会失败的进程。为什么命令无法成功?我已经 pip 安装了所有需要的包。但是下面显示错误:
Running a worker with superuser privileges when the worker accepts messages serialized with pickle is a very bad idea!
If you really want to continue then you have to set the C_FORCE_ROOT environment variable (but please think about this before you do).
User information: uid=0 euid=0 gid=0 egid=0
我试着搜索一些关于这个错误的博客,得到答案:
export C_FORCE_ROOT='true' # at the centos enviroument
要解决的措施(遇到这样的错误后)
将
export C_FORCE_ROOT='true'
添加到centos的环境文件中并获取它。检查命令'env/bin/python project/manage.py celeryd ',是否运行成功。
重启supervisord。请注意!不是
supervisorctl reload
,它只是重新加载 .conf 文件,而不是环境文件。尝试终止进程supervisord -c xx.conf
(ps aux | grep supervisord
和kill -9 process_number
,小心)。