Python 如何杀死所有 uwsgi 实例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31970908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 10:49:45  来源:igfitidea点击:

How to kill all instance of uwsgi

pythondjangouwsgi

提问by user2413621

I am trying to upload my project to the server. There is already a project in the server now. I have new project which I want to run and replace the old project with the new one, so I pull the new project to the server. Then I activate the virtual environment and do all the necessary work. Then when I try to run the command:

我正在尝试将我的项目上传到服务器。现在服务器中已经有一个项目了。我有一个新项目,我想运行并用新项目替换旧项目,所以我将新项目拉到服务器上。然后我激活虚拟环境并做所有必要的工作。然后当我尝试运行命令时:

uwsgi --plugins=python --chdir=/var/www/prjt/src/ --socket=127.0.0.1:8889 --module=prjt.wsgi:application &

it tell me that

它告诉我

probably another instance of uWSGI is running on the same address (127.0.0.1:8889).
bind(): Address already in use [core/socket.c line 761]

I searched for similar problems and found some solutions about killing all instance of uwsgi as mentioned in this answer herebut could not find how to do it.

我搜索了类似的问题,并找到了一些关于杀死所有 uwsgi 实例的解决方案,如这里的答案中提到的,但找不到如何去做。

回答by John Smith Optional

Add a pidfile to your command:

将 pidfile 添加到您的命令中:

uwsgi --plugins=python --chdir=/var/www/prjt/src/ --socket=127.0.0.1:8889 --module=prjt.wsgi:application --pidfile /tmp/myapp.pid

Then use

然后使用

uwsgi --stop /tmp/myapp.pid

to stop the uwsgi instance in a safe way.

以安全的方式停止 uwsgi 实例。

If you didn't specify a pidfile when you started the first instance, you can kill it brutally using

如果您在启动第一个实例时没有指定 pidfile,您可以使用

kill `pidof uwsgi`

回答by Eugen Konkov

I stop my uwsgi instance by command:

我通过命令停止我的 uwsgi 实例:

kill -INT `cat ${APP_ROOT}/run/uwsgi.pid`

This command sends signal to uwsgiwhich cause it to stop.

此命令向uwsgi发送信号,使其停止。

If you do not know PID than you may:

如果您不知道 PID,那么您可能会:

killall -s INT /ve/path/bin/uwsgi

The official documentation

官方文档

回答by Ninja420

you can get the pid of the uwsgi process here lsof -t -i tcp:8000

您可以在此处获取 uwsgi 进程的 pid lsof -t -i tcp:8000

and kill it then kill -9 pid

然后杀死它 kill -9 pid

回答by andilabs

for me the way to kill uwsgi instances in a bruteforce manner was:

对我来说,以蛮力方式杀死 uwsgi 实例的方法是:

sudo pkill -f uwsgi -9