I'm on a mac, doing:
我在mac上做:
rails server
rails服务器
I get:
我得到:
2010-12-17 12:35:15] INFO WEBrick 1.3.1
[2010-12-17 12:35:15] INFO ruby 1.8.7 (2010-08-16) [i686-darwin10.4.0]
[2010-12-17 12:35:15] WARN TCPServer Error: Address already in use - bind(2)
Exiting
I know I can start one on a new port, but I want to kill this process.
我知道我可以在一个新的端口上启动一个,但是我想要杀死这个过程。
9 个解决方案
#1
516
Assuming you're looking to kill whatever is on port 3000 (which is what webrick normally uses), type this in your terminal to find out the PID of the process:
假设您想要杀死端口3000 (webrick通常使用的是什么),在您的终端中输入这个,以找出过程的PID:
$ lsof -wni tcp:3000
Then, use the number in the PID column to kill the process:
然后,使用PID列中的数字来杀死进程:
$ kill -9 PID
#2
88
kill -9 $(lsof -i tcp:3000 -t)
kill -9 $(lsof -i tcp:3000 -t)
#3
22
You need to get process id of program using tcp port 3000. To get process id
您需要使用tcp端口3000来获取程序的进程id。获取进程id
lsof -i tcp:3000 -t
And then using that process id, simply kill process using ubuntu kill command.
然后使用这个过程id,简单地使用ubuntu kill命令杀死进程。
kill -9 pid
Or just run below mentioned combine command. It will first fetch pid and then kill that process.
或者只运行下面提到的组合命令。它将首先获取pid然后杀死这个过程。
kill -9 $(lsof -i tcp:3000 -t)
#4
15
For anyone stumbling across this question that is not on a Mac: assuming you know that your server is running on port 3000, you can do this in one shot by executing the following:
如果您知道您的服务器在3000端口上运行,那么您可以通过执行以下操作来实现这一点:
fuser -k 3000/tcp
But as Toby has mentioned, the implementation of fuser in Mac OS is rather primitive and this command will not work on mac.
但是正如Toby提到的,Mac OS中fuser的实现相当原始,这个命令在Mac上是行不通的。
#5
12
Some times there is a chance where rails server not closed properly. You can find process used by rails
有些时候,rails服务器可能无法正常关闭。您可以找到rails使用的过程。
ps aux | grep rails
pb0 grep轨道。
Output will be like
输出将像
user 12609 9.8 0.5 66456 45480 pts/0 Sl+ 21:06 0:02 /home/user/.rvm/rubies/ruby-2.2.0-preview1/bin/ruby bin/rails s
Here process_id 12609 is used by your rails server.
这里的process_id 12609被您的rails服务器使用。
You can kill it easily by command
你可以通过命令轻易地杀死它。
kill -9 12609
kill - 9 12609
#6
8
All the answers above are really good but I needed a way to type as little as possible in the terminal so I created a gem for that. You can install the gem only once and run the command 'shutup' every time you wanna kill the Rails process (while being in the current folder).
上面所有的答案都很好,但是我需要一种方法在终端上尽可能少的输入,所以我创建了一个gem。您可以只安装一次gem,每次当您想要杀死Rails进程时,运行命令“shutup”(在当前文件夹中)。
gem install shutup
gem安装密封
then go in the current folder of your rails project and run
然后进入rails项目的当前文件夹并运行。
shutup
# this will kill the Rails process currently running
这将杀死当前正在运行的Rails进程。
You can use the command 'shutup' every time you want
你可以在每次需要的时候使用“shutup”命令。
DICLAIMER: I am the creator of this gem
声明:我是这颗宝石的创造者。
NOTE: if you are using rvm install the gem globally
注意:如果您使用rvm在全球安装gem。
rvm @global do gem install shutup
#7
1
ps aux|grep rails use this command you can kill the server
使用此命令的ps aux|grep rails可以杀死服务器。
#8
-4
Type in:
类型:
man lsof
Then look for -w, -n, and -i
然后找-w, -n,和-i。
-i: internet stuff -n: makes it faster -w: toggles warnings
i:互联网上的东西-n:让它更快-w:切换警告。
There are WAY more details on the man pages
关于手册页有更多的细节。
#9
-6
If you are on windows machine follow these steps.
如果您在windows机器上,请遵循以下步骤。
c:/project/
cd tmp
c:/project/tmp
cd pids
c:/project/tmp/pids
dir
There you will a file called server.pid
你会看到一个名为server.pid的文件。
delete it.
删除它。
c:/project/tmp/pid> del *.pid
Thats it.
这是它。
EDIT: Please refer this
编辑:请参考
#1
516
Assuming you're looking to kill whatever is on port 3000 (which is what webrick normally uses), type this in your terminal to find out the PID of the process:
假设您想要杀死端口3000 (webrick通常使用的是什么),在您的终端中输入这个,以找出过程的PID:
$ lsof -wni tcp:3000
Then, use the number in the PID column to kill the process:
然后,使用PID列中的数字来杀死进程:
$ kill -9 PID
#2
88
kill -9 $(lsof -i tcp:3000 -t)
kill -9 $(lsof -i tcp:3000 -t)
#3
22
You need to get process id of program using tcp port 3000. To get process id
您需要使用tcp端口3000来获取程序的进程id。获取进程id
lsof -i tcp:3000 -t
And then using that process id, simply kill process using ubuntu kill command.
然后使用这个过程id,简单地使用ubuntu kill命令杀死进程。
kill -9 pid
Or just run below mentioned combine command. It will first fetch pid and then kill that process.
或者只运行下面提到的组合命令。它将首先获取pid然后杀死这个过程。
kill -9 $(lsof -i tcp:3000 -t)
#4
15
For anyone stumbling across this question that is not on a Mac: assuming you know that your server is running on port 3000, you can do this in one shot by executing the following:
如果您知道您的服务器在3000端口上运行,那么您可以通过执行以下操作来实现这一点:
fuser -k 3000/tcp
But as Toby has mentioned, the implementation of fuser in Mac OS is rather primitive and this command will not work on mac.
但是正如Toby提到的,Mac OS中fuser的实现相当原始,这个命令在Mac上是行不通的。
#5
12
Some times there is a chance where rails server not closed properly. You can find process used by rails
有些时候,rails服务器可能无法正常关闭。您可以找到rails使用的过程。
ps aux | grep rails
pb0 grep轨道。
Output will be like
输出将像
user 12609 9.8 0.5 66456 45480 pts/0 Sl+ 21:06 0:02 /home/user/.rvm/rubies/ruby-2.2.0-preview1/bin/ruby bin/rails s
Here process_id 12609 is used by your rails server.
这里的process_id 12609被您的rails服务器使用。
You can kill it easily by command
你可以通过命令轻易地杀死它。
kill -9 12609
kill - 9 12609
#6
8
All the answers above are really good but I needed a way to type as little as possible in the terminal so I created a gem for that. You can install the gem only once and run the command 'shutup' every time you wanna kill the Rails process (while being in the current folder).
上面所有的答案都很好,但是我需要一种方法在终端上尽可能少的输入,所以我创建了一个gem。您可以只安装一次gem,每次当您想要杀死Rails进程时,运行命令“shutup”(在当前文件夹中)。
gem install shutup
gem安装密封
then go in the current folder of your rails project and run
然后进入rails项目的当前文件夹并运行。
shutup
# this will kill the Rails process currently running
这将杀死当前正在运行的Rails进程。
You can use the command 'shutup' every time you want
你可以在每次需要的时候使用“shutup”命令。
DICLAIMER: I am the creator of this gem
声明:我是这颗宝石的创造者。
NOTE: if you are using rvm install the gem globally
注意:如果您使用rvm在全球安装gem。
rvm @global do gem install shutup
#7
1
ps aux|grep rails use this command you can kill the server
使用此命令的ps aux|grep rails可以杀死服务器。
#8
-4
Type in:
类型:
man lsof
Then look for -w, -n, and -i
然后找-w, -n,和-i。
-i: internet stuff -n: makes it faster -w: toggles warnings
i:互联网上的东西-n:让它更快-w:切换警告。
There are WAY more details on the man pages
关于手册页有更多的细节。
#9
-6
If you are on windows machine follow these steps.
如果您在windows机器上,请遵循以下步骤。
c:/project/
cd tmp
c:/project/tmp
cd pids
c:/project/tmp/pids
dir
There you will a file called server.pid
你会看到一个名为server.pid的文件。
delete it.
删除它。
c:/project/tmp/pid> del *.pid
Thats it.
这是它。
EDIT: Please refer this
编辑:请参考