Some applications create a PID file - a file that stores the process identifier of the application. The Mongrel server (and I think WEBrick too) creates a PID file in an application’s root directory at e.g. [app]/tmp/pids/mongrel.pid.
You can use the cat
command to pass the PID from this file to the kill
command in order to terminate the process gracefully.
kill -TERM $(cat tmp/pids/mongrel.pid)
Or send a kill signal, which forces the termination:
kill -KILL $(cat tmp/pids/mongrel.pid)
kill -9 $(cat tmp/pids/mongrel.pid)