Doing Hart's Rails Tutorial, but server won't shut down for me fire it up after updates

ぐ巨炮叔叔 提交于 2019-12-11 12:33:56

问题


I have made some changes to various files, and need to shut down and then restart the server to see them. I am using the Cloud9 railstutorial environment. But I keep getting the same error - "A server is already running". Please see below:

darrenbrett:~/workspace/sample_app (filling-in-layout) $ rails server -b $IP -p $PORT
=> Booting WEBrick
=> Rails 4.2.2 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server

A server is already running. Check /home/ubuntu/workspace/sample_app/tmp/pids/server.pid.
Exiting
darrenbrett:~/workspace/sample_app (filling-in-layout) $ 

回答1:


Find out the process id (PID) first:

$ lsof -wni tcp:8080

This will give you something like this:

$ lsof -wni tcp:8080 

COMMAND   PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ruby    59656 rislam   14u  IPv6 0xa86b8563672ef037      0t0  TCP [::1]:http-alt (LISTEN)

Then, kill the process with PID = 59656 (for example, it will be different for you):

$ kill -9 59656

This should solve your problem.

You can also use the following command to kill all running apps that has rails in the name:

killall -9 rails

Sometimes, this is very effective when the first command does not do the trick.




回答2:


It sounds like you either have an orphaned server process running, or you have multiple applications in the same environment and you're running the server for another one and it's bound to the same port. I'm guessing the former.

Run ps -fe | grep rails. You should see something like 501 35861 2428 0 1:55PM ttys012 0:04.00 /your_file_path/ruby bin/rails server

Grab the process id (in the case of the example, it's 35861), and run kill -9 35861. Then try to start your server again.




回答3:


The easiest way I found to kill that server is to click on the suggested file in the line:

A server is already running. Check /home/ubuntu/workspace/sample_app/tmp/pids/server.pid

That opens the file containing a number, the process id you're looking for.

Example

43029

In the terminal window use "kill" via that same process id and restart the server.

kill -15 43029
rails server -b $IP -p $PORT


来源:https://stackoverflow.com/questions/33455826/doing-harts-rails-tutorial-but-server-wont-shut-down-for-me-fire-it-up-after

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!