如何阻止芹菜工人的过程 [英] How to stop celery worker process

查看:155
本文介绍了如何阻止芹菜工人的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu EC2节点上有一个Django项目,我一直在使用 Celery 来设置异步。



我正在追踪这个



我已经能够在命令行中使用以下功能获得基本任务:

 (env1)ubuntu @ ip-172-31-22-65:〜/ projects / tp $ celery --app = myproject.celery:app worker --loglevel = INFO 

启动工作人员。我已经对Python做了一些修改,但意识到需要重新启动一个worker。



从命令行,我试过:

  ps auxww | grep'芹菜工'| awk'{print $ 2}'| xargs kill -9 

但是我可以看到工作人员还在运行。



如何杀死它?



编辑:



ubuntu @ ip-172-31-22-65:〜/ projects / tp $ sudo ps auxww | grep celeryd | grep -vgrep| awk'{print $ 2}'| sudo xargs kill -HUP
kill:invalid argument H

用法:
kill [options]< pid> [...]

选项:
< pid> [...]发送信号到每个< pid>列出的
- < signal>,-s, - 信号< signal>
指定< signal>要发送
-l,--list = [< signal>]列出所有信号名称,或将一个转换为名称
-L,--table列出一个好的表中的所有信号名称

-h,--help显示此帮助并退出
-V,--version输出版本信息并退出

有关详细信息,请参阅kill(1)。

编辑2:

 (env1)ubuntu @ ip-172-31-22-65:〜/ projects / tp $ ps aux | grep芹菜
ubuntu 9756 0.0 3.4 100868 35508 pts / 6 S + 15:49 0 :07 /home/ubuntu/.virtualenvs/env1/bin/python3.4 /home/ubuntu/.virtualenvs/env1/bin/celery --app = tp.celery:app worker --loglevel = INFO
ubuntu 9760 0.0 3.9 255840 39852 pts / 6 S + 15:49 0:05 /home/ubuntu/.virtualenvs/env1/bin/python3.4 /home/ubuntu/.virtualenvs/env1/bin/celery --app = tp.celery :app worker --loglevel = INFO
ubuntu 12760 0.0 0.0 10464 932 pts / 7 S + 19:04 0:00 grep --color = auto celery


解决方案

在终端中尝试此方法

  ps aux | grep'芹菜工人'

你会看到这样的

 用户名29042 0.0 0.6 23216 14356 pts / 1 S + 00:18 0:01 / bin /芹菜工人... 

然后kill进程id by

  sudo kill -9 process_id#here 29042 

如果你有多个进程,那么你必须使用上面的 kill {/ code> commmand

  sudo kill -9 id1 id2 id3 ... 

从芹菜doc

  ps auxww | grep'芹菜工'| awk'{print $ 2}'| xargs kill -9 

或者如果您正在运行 celeryd

  ps auxww | grep celeryd | awk'{print $ 2}'| xargs kill -9 

注意



如果您在 supervisor 中运行 celery ,即使终止进程,它会自动重新启动(如果在主管脚本中autorestart = True)。



希望这有助于


I have a Django project on an Ubuntu EC2 node, which I have been using to set up an asynchronous using Celery.

I am following this along with the docs.

I've been able to get a basic task working at the command line, using:

(env1)ubuntu@ip-172-31-22-65:~/projects/tp$ celery --app=myproject.celery:app worker --loglevel=INFO

To start a worker. I have since made some changes to the Python, but realized that I need to restart a worker.

From the command line, I've tried:

 ps auxww | grep 'celery worker' | awk '{print $2}' | xargs kill -9

But I can see that the worker is still running.

How can I kill it?

edit:

(env1)ubuntu@ip-172-31-22-65:~/projects/tp$ sudo ps auxww | grep celeryd | grep -v "grep" | awk '{print $2}' | sudo xargs kill -HUP
kill: invalid argument H

Usage:
 kill [options] <pid> [...]

Options:
 <pid> [...]            send signal to every <pid> listed
 -<signal>, -s, --signal <signal>
                        specify the <signal> to be sent
 -l, --list=[<signal>]  list all signal names, or convert one to a name
 -L, --table            list all signal names in a nice table

 -h, --help     display this help and exit
 -V, --version  output version information and exit

For more details see kill(1).

edit 2:

(env1)ubuntu@ip-172-31-22-65:~/projects/tp$ ps aux|grep celery
ubuntu    9756  0.0  3.4 100868 35508 pts/6    S+   15:49   0:07 /home/ubuntu/.virtualenvs/env1/bin/python3.4 /home/ubuntu/.virtualenvs/env1/bin/celery --app=tp.celery:app worker --loglevel=INFO
ubuntu    9760  0.0  3.9 255840 39852 pts/6    S+   15:49   0:05 /home/ubuntu/.virtualenvs/env1/bin/python3.4 /home/ubuntu/.virtualenvs/env1/bin/celery --app=tp.celery:app worker --loglevel=INFO
ubuntu   12760  0.0  0.0  10464   932 pts/7    S+   19:04   0:00 grep --color=auto celery

解决方案

Try this in terminal

ps aux|grep 'celery worker'

You will see like this

username  29042  0.0  0.6  23216 14356 pts/1    S+   00:18   0:01 /bin/celery worker ...

Then kill process id by

sudo kill -9 process_id # here 29042

If you have multiple processes, then you have to kill all process id using above kill commmand

sudo kill -9 id1 id2 id3 ...

From the celery doc

ps auxww | grep 'celery worker' | awk '{print $2}' | xargs kill -9

OR if you are running celeryd

ps auxww | grep celeryd | awk '{print $2}' | xargs kill -9

Note

If you are running celery in supervisor, even though kill the process, it automatically restarts(if autorestart=True in supervisor script).

Hope this helps

这篇关于如何阻止芹菜工人的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆