Ruby-on-rails 阻止 Unicorn Server 进程运行的最佳方法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4749963/
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-09-03 00:09:31  来源:igfitidea点击:

What is the best way to stop a Unicorn Server process from running?

ruby-on-rails

提问by ChuckJHardy

What is the best way to stop a Unicorn Server process from running? Whenever I try to stop it using kill -p 90234it does not work. It is most likely something I am doing wrong.

阻止 Unicorn Server 进程运行的最佳方法是什么?每当我尝试停止使用kill -p 90234它时,它都不起作用。这很可能是我做错了什么。

Thanks.

谢谢。

采纳答案by Slawomir Wdowka

Simple Things There - In Terminal type "ps" and have a look for the Master Unicorn Process. Copy the PID of it and then type "kill ?9 90234" (where 90234 is PID of master unicorn process). After that worker process should disappear itself.

简单的事情 - 在终端输入“ps”并查看 Master Unicorn Process。复制它的PID,然后输入“kill ?9 90234”(其中90234是主独角兽进程的PID)。在那之后,工作进程应该自己消失。

回答by Rob Cameron

Have a look at the Unicorn SIGNALS page. If the master is behaving correctly and you just want to turn it off, you should send a QUIT signal:

看看独角兽信号页面。如果主机运行正常而您只想将其关闭,则应发送 QUIT 信号:

kill -QUIT 1234     # where 1234 is the real process id, of course

That gracefully stops all the workers, letting them finish any requests that they're in the middle of serving.

这会优雅地停止所有工作人员,让他们完成他们正在服务的任何请求。

回答by clem

I use this:

我用这个:

ps aux | grep 'unicorn' | awk '{print }' | xargs sudo kill -9

I just looked back at this two months later. This is craziness, and don't use this if you have more than one Unicorn master and you only want to kill one of them.

两个月后我才回头看。这太疯狂了,如果你有不止一个独角兽大师并且你只想杀死其中一个,请不要使用它。

回答by osburnsharp

Interesting that no-one considered the pid file that unicorn creates? My usual config puts it in ./tmp/unicorn.pid, so perhaps the safest way is

有趣的是没有人考虑过独角兽创建的 pid 文件?我通常的配置将它放在 ./tmp/unicorn.pid 中,所以也许最安全的方法是

kill -QUIT `cat tmp/unicorn.pid`

and the pid file is then properly deleted by the departing process. I always put the pid file in the same relative place so I guess I could alias that for convenience, although when I am developing I don't usually daemonize unicorn.

然后pid文件被离开的进程正确删除。我总是把 pid 文件放在同一个相对位置,所以我想我可以为方便起见为它取别名,尽管在我开发时我通常不会守护独角兽。

回答by mikewilliamson

I would probably go with:

我可能会选择:

sudo pkill unicorn_rails

回答by fl00r

ps aux | grep unicorn
#=> root   4393  2.0  0.9  65448 20764 ?  S  20:06   0:35 unicorn_rails m
kill 4393

回答by Chiedo

Ultimately, the key is the following line which targets the master unicorn process and kills it

最终,关键是以下一行,它针对主独角兽进程并杀死它

kill $(ps aux | grep '[u]nicorn_rails master' | awk '{print }')

回答by orlp

Usually I'm lazy and I just kill by name:

通常我很懒,我只是按名字杀:

$ killall processname

回答by timurb

To quit a specific Unicorn server you can use something like the following:

要退出特定的 Unicorn 服务器,您可以使用以下内容:

pkill -QUIT --pidfile /path/to/app/shared/tmp/pids/unicorn.pid

This way you can selectively kill any process and you don't have to use shell evaluation/expansion which may not be available.

通过这种方式,您可以有选择地终止任何进程,而不必使用可能不可用的 shell 评估/扩展。

回答by Victor Pudeyev

for those using chef and seeing that none of the above works (because the processes are respawned as soon as you kill them):

对于那些使用厨师并看到以上都不起作用的人(因为一旦您杀死它们,这些进程就会重新生成):

sudo sv stop APP_NAME

sudo sv stop APP_NAME

svis the control for runit.

sv是 的控制runit