If you find yourself in this situation like ‘A server is already running’ often you know how annoying this is. This happens depending on you terminal settings or when you have many tabs open and you don’t know where Rails is running, but you wanna stop the server. And all the times you get the error ‘A server is already running.’.
How to fix that:
=> Run `rails server -h` for more startup options => Ctrl-C to shutdown server A server is already running. Check /tmp/pids/server.pid. Exiting
cat /tmp/pids/server.pid kill -9 PID
But this is boring. And you have to do it all the times. I created a shortcut for that, it is called ‘shutup’.
It is a gem that reads the current process id in the current Rails folder and sends a ‘kill -9 PID’ to the machine killing the it.
Installation of Shutup
$ cd # in the project folder $ gem install shutup
Installation (if using rvm)
$ cd # in the project folder $ rvm @global do gem install shutup
After installing the gem run:
$ cd # in the project folder $ shutup
TEST IT: try to start the Rails app, open a new terminal window and then type:
To see how this gem kills the current process.
Let me know if you find this useful.comments powered by Disqus