简体   繁体   English

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

[英]How do I shutdown a rails server without a console?

I started a " rails server " in my Mac OS X terminal. 我在Mac OS X终端中启动了“ rails server ”。 Supposedly if I just hit Ctrl + c in that terminal, I can shut it down. 据说如果我只是在该终端按Ctrl + c ,我可以将其关闭。 But I accidentally closed the terminal and now I can't shut it down. 但我不小心关闭了终端,现在我无法关闭它。

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? 有人可以帮忙吗?

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. 虽然我已经看到Ruby和/或Rails应用程序,但应该在窗口关闭时应用程序已经死亡。 You can have the system tell you if any "ruby" or "rails" apps are running with one of these commands: 您可以让系统告诉您是否使用以下命令之一运行任何“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. 第二列中的数字是进程ID。 kill -9 14461 would kill it. kill -9 14461会杀了它。 Or, like above the killall command will do it by searching for apps with rails in the name. 或者,如上所述, killall命令将通过搜索名称中带有rails应用程序来执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM