我在mac上,做:

rails server

我得到:

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

我知道我可以在一个新的端口上启动一个进程,但是我想终止这个进程。


当前回答

类型:

man lsof

然后寻找-w -n和-i

-i:网络东西 -n:加快速度 -w:切换警告

手册页上有更多的细节

其他回答

如果你使用的是windows机器,请遵循以下步骤。

c:/project/
cd tmp
c:/project/tmp
cd pids
c:/project/tmp/pids
dir

这里有一个名为server.pid的文件

删除它。

c:/project/tmp/pid> del *.pid

这是它。

编辑:请参考这个

一句话解决方案:

kill -9 $(ps aux | grep 'rails s' | awk {'print$2'}); rails s

Kill -9 $(lsof -i tcp:3000 -t)

使用此命令可以关闭服务器:

ps aux|grep rails 

这是一个在windows中杀死进程的WSL脚本

PIDS=$(/mnt/c/windows/system32/cmd.exe /c netstat -ano | /mnt/c/windows/system32/cmd.exe /c findstr :$1 | awk '{print $5}')
for pid in $PIDS
do
    /mnt/c/windows/system32/cmd.exe /c wmic process where "processid=$pid" delete
done

例子

myscriptname 8080