On OSX, you can take advantage of the UNIX-like command line - here's what I keep handy in my .bashrc to enable me to more easily restart a server that's running in background (-d) mode (note that you have to be in the Rails root directory when running this):
alias restart_rails='kill -9 `cat tmp/pids/server.pid`; rails server -d'
My initial response to the comment by @zane about how the PID file isn't removed was that it might be behavior dependent on the Rails version or OS type. However, it's also possible that the shell runs the second command (rails server -d
) sooner than the kill
can actually cause the previous running instance to stop.
So alternatively, kill -9 cat tmp/pids/server.pid && rails server -d
might be more robust; or you can specifically run the kill
, wait for the tmp/pids
folder to empty out, then restart your new server.