简体   繁体   English

即使服务器关闭后,Rails服务器也已在运行,仅在退出终端后才能再次运行

[英]Rails Server Already Running even after server shutdown, only works again after exiting terminal

I'm using Rails 4.0 on Mountain Lion. 我在Mountain Lion上使用Rails 4.0。

I've looked at other questions on SO regarding this problem, but the answers I've seen are to simply delete the server.pid file in question. 我已经看过关于此问题的其他问题,但是我看到的答案是简单地删除有问题的server.pid文件。 Doing so is only a temporary fix for me, as it reappears when I start the server again and does not go away. 这样做对我来说只是一个临时解决方案,因为它会在我再次启动服务器时重新出现并且不会消失。 (Or rather, the PID number within the file does not go away). (或者,文件中的PID编号不会消失)。 I'm not trying to run multiple servers, only trying to be able to shut down the server within the terminal and then start it back up. 我不是要运行多个服务器,而只是想能够关闭终端中的服务器,然后再启动它。

When I open a fresh terminal and start a rails server it works the first time. 当我打开一个新的终端并启动Rails服务器时,它第一次工作。 If I shut the server down, and try to restart it again, I'm given the "Already Running" message. 如果我关闭服务器,然后尝试重新启动它,则会收到“已经运行”消息。 Now, what works is if I completely exit the terminal, and open a new terminal window. 现在,有效的方法是我完全退出终端,然后打开一个新的终端窗口。 But this is getting rather tedious. 但这变得相当乏味。 Does anyone know what the deal might be? 有人知道这笔交易会是什么吗?

Use control-C to shutdown rails properly. 使用control-C正确关闭滑轨。

If you are running a tailing command, like rails does, you use control-C to shut it down correctly. 如果您正在像rails一样运行拖尾命令,则可以使用control-C将其正确关闭。

If you are running a console command such as SSH, PostgreSQL, or Rails Console, you use control-D to exit properly. 如果运行的是SSH,PostgreSQL或Rails Console之类的控制台命令,则可以使用control-D正确退出。

I have no idea why (maybe someone can tell me), but that is how it is. 我不知道为什么(也许有人可以告诉我),但是事实就是如此。

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

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