I am running my rails application using the following
$script/server -d webrick
on my Ubuntu system , above command run the webrick s
The only proper way to kill the Ruby on Rails default server (which is WEBrick) is:
kill -INT $(cat tmp/pids/server.pid)
If you are running Mongrel, this is sufficient:
kill $(cat tmp/pids/server.pid)
Use kill -9
if your daemon hung. Remember the implications of kill -9
- if the data kept in Active Record caches weren't flushed to disk, you will lose your data. (As I recently did)
i don't think it does if you use -d. I'd just kill the process.
In the future, just open up another terminal window instead and use the command without -d, it provides some really useful debugging output.
If this is production, use something like passenger or thin, so that they're easy to stop the processes or restart the servers
if it can be useful, on linux you can find which process is using a port (in this case 3000) you can use:
lsof -i :3000
it'll return the pid too
You can start your server in the background by adding -d
to your command. For instance:
puma -d
To stop it, just kill whatever process is running on port 3000:
kill $(cat tmp/pids/server.pid)
The process id of the daemon server is stored in your application directory tmp/pids/. You can use your standard kill process_id
with the information you find there.
one-liner: kill -INT `ps -e | grep ruby | awk '{print $1}'`
ps -e
lists every process on the system
grep ruby
searches that output for the ruby process
awk
passes the first argument of that output
(the pid) to kill -INT
.
Try it with echo instead of kill if you just want to see the PID.