Reputation: 3503
I know how to start a Rails server with
rails server
But now i started the rails server with daemon. The result is that the server runs in the background and the commandline is accessible. Hoe can I stop this server that is running in the background. So how do I end this code?
rails server --daemon
Upvotes: 1
Views: 6007
Reputation: 463
The default port used by a Rails server (WEBrick) is 3000. If you simply started the server with the command mentioned, use:
kill -9 $(lsof -i tcp:3000 -t)
Or you can replace the port in 'tcp:3000' with the port used in case you used some different port, although it doesn't seem so as per the details provided by you.
To list all processes which are using network, use this:
lsof -i
You can find a process listening on localhost here, use that process ID (PID) in
kill -9 PID
Upvotes: 4
Reputation: 492
There's no easy way that I know of, but you should be able to run
kill -9 $(cat tmp/pids/server.pid)
Upvotes: 6