码迷,mamicode.com
首页 > 其他好文 > 详细

celery beat 之Pidfile (celerybeat.pid) already exists报错

时间:2019-09-22 10:27:32      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:django   alt   保存   jpg   pid   运行时   利用   idf   already   

celery beat 之Pidfile (celerybeat.pid) already exists报错

今天在django中利用celery来自动添加任务时,执行celery beat -A celery_task -l info启动一个添加任务的服务时报错:Pidfile (celerybeat.pid) already exists

技术图片

报错原因

celery beat在运行时,会自动创建两个文件:

  • pidfile:默认为celerybeat.pid,保存在项目根目录。
  • scheduler:默认为celerybeat-schedule,保存在项目根目录。

这里的报错说明pidfile已存在。上次运行的时候,已经自动创建了,进程结束的时候并未自动删除,从而导致再次运行的时候报错了。

解决方法

直接删除这个pidfile文件,再次启动celery beat

celery beat -A celery_task -l info

运行成功了。

那么难道每次重启都得先删除么?参考网上说法,如果在启动celery beat的时候配置pidfile参数,并将该参数设置为空,可以规避这个问题。

celery beat 之Pidfile (celerybeat.pid) already exists报错

标签:django   alt   保存   jpg   pid   运行时   利用   idf   already   

原文地址:https://www.cnblogs.com/863652104kai/p/11565764.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!