greatghoul
Ask and Learn

Follow

Ask and Learn

Follow
快速杀掉失去响应 rails 进程

Photo by Gabriel Heinzer on Unsplash

快速杀掉失去响应 rails 进程

greatghoul's photo
greatghoul
·May 17, 2020·

1 min read

在 Ruby on Rails 的日常开发时,有时候不小心写出个坏代码(比如死循环),导致 rails dev server 进程失去响应,这时候如果想杀掉进程,按 Cmd+C 可能没有效果。

除了去 grep ps 或者查看 server.pid 外,还有一个快捷的方法快速结束进程。

按下 Cmd+Z,进程会自动转到后台运行,此时终端上会输出进程 PID

Puma starting in single mode...
* Version 3.12.0 (ruby 2.6.1-p33), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
^Z
[1]  + 63939 suspended  rails s

kill 掉它就可以了。

$ kill -9 63939
 
Share this