环境
描述:项目主要是是基于celery和supervisor+redis+bottle这些来组成,
在bottle运行的时候,为提高响应的速度,部分的处理转移给了celery做异步。但是在部署的时候出现了一些问题。
问题
相关的项目已部署完成,在运行的celery -A async_tasks worker
的时候出现了各种问题
1:开始以为是使用的python环境不对,需要修改一下/usr/bin/celery 文件的下的python环境,但是启动还是不行
2:仔细查看对应的错误日式是说redis连接的时候密码连接有问题,去除中文的redis密码,再次启动。
3:这时候出现先的问题是 说是找不到命令,但是我直接的使用 celery -A async_tasks worker到对应的目录下执行是可以的
[root@web1 xxxx_sys2]# celery -A async_tasks worker --loglevel=info
xxxxxxx
4:修改c/usr/bin/celery--->elery
[program:celery_for_xxxxxx]
command=celery -A async_tasks worker ;supervisord将要执行的运行celery服务的命令
directory=/data/www/xxxxxxxx_sys2
stdout_logfile=/data/logs/celery/xxxxxx_sys2_celery.log ; supervisord当前这个test服务运行产生的日志存储路径,方便我们查看运行情况
socket-timeout=3
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
查看实时日志不输出
image.png
5:重启的启动还是找不到对应的命令,或文件找不到,重新找其他问题,还是无法使用supervisor来启动
[root@web1 iread_business_management_sys2]# supervisorctl
celery_for_iread_business FATAL Exited too quickly (process log
其他错误:
image.png
6:尝试使用supervisor 重新的reload 所有的进程!-OK!启动成功了!
[root@web1 iread_business_management_sys2]# ps -ef|grep celery
root 11160 10489 0 19:05 pts/0 00:00:00 grep --color=auto celery
[root@web1 iread_business_management_sys2]# ps -ef|grep celery
root 11162 10489 0 19:05 pts/0 00:00:00 grep --color=auto celery
[root@web1 iread_business_management_sys2]# ps -ef|grep celery
root 11164 10489 0 19:05 pts/0 00:00:00 grep --color=auto celery
[root@web1 iread_business_management_sys2]# ps -ef|grep celery
root 11167 10489 0 19:05 pts/0 00:00:00 grep --color=auto celery
[root@web1 iread_business_management_sys2]# ps -ef|grep celery
root 11169 10489 0 19:05 pts/0 00:00:00 grep --color=auto celery
[root@web1 iread_business_management_sys2]#
[root@web1 iread_business_management_sys2]# supervisorctl
celery_for_iread_business FATAL can't find command '/usr/bin/celery'
cu_iread_web_server_qt RUNNING pid 11061, uptime 0:07:20
cu_iread_web_server_qt2 RUNNING pid 11060, uptime 0:07:20
iread_business_management_sys2_1 RUNNING pid 11058, uptime 0:07:20
iread_business_management_sys2_2 RUNNING pid 11059, uptime 0:07:20
test RUNNING pid 11062, uptime 0:07:20
supervisor> reload
Really restart the remote supervisord process y/N? y
Restarted supervisord
supervisor> status
celery_for_iread_business STARTING
cu_iread_web_server_qt STARTING
cu_iread_web_server_qt2 STARTING
iread_business_management_sys2_1 STARTING
iread_business_management_sys2_2 STARTING
test STARTING
supervisor> status
celery_for_iread_business RUNNING pid 11175, uptime 0:00:18
cu_iread_web_server_qt RUNNING pid 11176, uptime 0:00:18
cu_iread_web_server_qt2 RUNNING pid 11174, uptime 0:00:18
iread_business_management_sys2_1 RUNNING pid 11172, uptime 0:00:18
iread_business_management_sys2_2 RUNNING pid 11173, uptime 0:00:18
test RUNNING pid 11177, uptime 0:00:18
supervisor>
--------------------------------------------------2018年3月21日 17:17:02------------------------------------
PS:如果线上使用到其他celcey启动多个任务对象,需要使用不对的数据库ID,如:
celery_for_iread_business
celery_for_ixxxxxxxx-------对应的不同任务,配置的数据库ID 也需要不一样
网友评论