无法停止 Rails 服务器 [英] Can't stop rails server
问题描述
我是 Rails 的新手,我正在使用 ubuntu 机器和 rubymine IDE.问题是我无法停止 Rails 服务器.我试图通过杀死 rails 进程来停止服务器.但是,当我运行 pgrep -l rails
时,没有找到这样的进程.所以,我只能杀死 ruby 进程,但是,服务器不会停止.
I am new to rails and I am using an ubuntu machine and the rubymine IDE. The problem is that I am unable to stop the rails server. I tried to stop the server by killing the rails process. But, when I run pgrep -l rails
, no such process is found. So, I am only able to kill ruby processes, but, the server won't stop.
我尝试了 ./script/server stop
(因为我是通过运行 ./script/server start
启动它的),但是,这不起作用.谷歌搜索并找到一些stackoverflow帖子,我尝试更改本地主机端口的侦听端口但没有成功.有人可以帮忙吗?
I tried ./script/server stop
(since I started it by running ./script/server start
), but, that didn't work. Googling around and finding some stackoverflow posts, I tried to change the localhost port's listening port but without success. Could someone help?
推荐答案
您可以使用其他端口,如下所示:
You can use other ports like the following:
rails server -p 3001
通常在您的终端中,您可以尝试 Ctrl + C
关闭服务器.
Normally in your terminal you can try Ctrl + C
to shutdown the server.
另一种杀死 Ruby on Rails 默认服务器(WEBrick
)的方法是:
The other way to kill the Ruby on Rails default server (which is WEBrick
) is:
kill -INT $(cat tmp/pids/server.pid)
在你的终端中找出进程的PID:
In your terminal to find out the PID of the process:
$ lsof -wni tcp:3000
然后,使用PID列中的数字杀死进程:
Then, use the number in the PID column to kill the process:
例如:
$ kill -9 PID
我发现的其他一些答案是:
And some of the other answers i found is:
要在运行时停止 rails 服务器,请按:
To stop the rails server while it's running, press:
CTRL-C
CTRL-Z
您将重新获得对 bash
的控制权.然后输入(不带 $
):
You will get control back to bash
. Then type (without the $
):
$ fg
这将返回到进程中,然后正确退出Rails s
.
And this will go back into the process, and then quit out of Rails s
properly.
这有点烦人,但这肯定胜过手动终止进程.还不错,是我能想到的最好的.
It's a little annoying, but this sure beats killing the process manually. It's not too bad and it's the best I could figure out.
您可以使用 killall -9 rails
杀死名称中带有rails
"的所有正在运行的应用程序.
You can use killall -9 rails
to kill all running apps with "rails
" in the name.
killall -9 rails
这篇关于无法停止 Rails 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!