如何在没有控制台的情况下关闭rails服务器?

时间:2022-12-27 20:46:49

I started a "rails server" in my Mac OS X terminal. Supposedly if I just hit Ctrl+c in that terminal, I can shut it down. But I accidentally closed the terminal and now I can't shut it down.

我在Mac OS X终端上启动了“rails服务器”。据说如果我只是在那个终端按Ctrl + c,我可以关闭它。但我不小心关闭了终端,现在我无法关闭它。

I started another test project and try "rails server" again, and I got

我开始了另一个测试项目并再次尝试“rails server”,我得到了

Address already in use - bind(2) (Errno::EADDRINUSE)" error.

已经在使用的地址 - bind(2)(Errno :: EADDRINUSE)“错误。

Can anyone help?

有人可以帮忙吗?

1 个解决方案

#1


28  

You can use killall -9 rails to kill all running apps with "rails" in the name.

您可以使用killall -9 rails来杀死名称中带有“rails”的所有正在运行的应用程序。

The app should have died when the window closed though I have seen Ruby and/or Rails apps stick. You can have the system tell you if any "ruby" or "rails" apps are running with one of these commands:

虽然我已经看到Ruby和/或Rails应用程序,但该应用程序应该在窗口关闭时死亡。您可以让系统告诉您是否有任何“ruby”或“rails”应用程序正在运行以下命令之一:

ps auxw | grep ruby
ps auxw | grep rails`

This is the output of the first one:

这是第一个的输出:

greg     14461   0.3  0.7  2483432  15000 s001  S+   10:10PM   1:03.43 /Users/greg/.rvm/rubies/ruby-1.9.2-p0/bin/ruby script/rails c

You can see the path to the running app which will help identify the job. The number in the second column is the process ID. kill -9 14461 would kill it. Or, like above the killall command will do it by searching for apps with rails in the name.

您可以看到正在运行的应用程序的路径,这将有助于识别作业。第二列中的数字是进程ID。杀死-9 14461会杀了它。或者,如上所述,killall命令将通过搜索名称中带有rails的应用程序来执行此操作。

#1


28  

You can use killall -9 rails to kill all running apps with "rails" in the name.

您可以使用killall -9 rails来杀死名称中带有“rails”的所有正在运行的应用程序。

The app should have died when the window closed though I have seen Ruby and/or Rails apps stick. You can have the system tell you if any "ruby" or "rails" apps are running with one of these commands:

虽然我已经看到Ruby和/或Rails应用程序,但该应用程序应该在窗口关闭时死亡。您可以让系统告诉您是否有任何“ruby”或“rails”应用程序正在运行以下命令之一:

ps auxw | grep ruby
ps auxw | grep rails`

This is the output of the first one:

这是第一个的输出:

greg     14461   0.3  0.7  2483432  15000 s001  S+   10:10PM   1:03.43 /Users/greg/.rvm/rubies/ruby-1.9.2-p0/bin/ruby script/rails c

You can see the path to the running app which will help identify the job. The number in the second column is the process ID. kill -9 14461 would kill it. Or, like above the killall command will do it by searching for apps with rails in the name.

您可以看到正在运行的应用程序的路径,这将有助于识别作业。第二列中的数字是进程ID。杀死-9 14461会杀了它。或者,如上所述,killall命令将通过搜索名称中带有rails的应用程序来执行此操作。