Rails – Stop the Rails Web Server by Command

The following command could start the Rails daemon server for you Rails web application.

  • rails s

 

Stopping the web server could be done by simply enter the Ctrl + C command in the terminal. But if your terminal session is disconnected, you have no way to stop the service. In that case, you have to kill the process directly.

First, find out the process ID of the Rails web server.

  • ps -ef | grep script/rails


 

Kill the process directly

  • kill -9 <Process ID>

 

Actually i wonder if there is a better way to stop the Rails web server. If you know it, please let me know. =P

Done =)

Reference: How to stop the server in Rails

Update @ 2013-05-23: varmaavinash01 made a bash function for stopping the Rails Web Server. Thanks. =)

Advertisements

6 thoughts on “Rails – Stop the Rails Web Server by Command”

  1. To kill rails server I made a bash function :

    function killthis() {
      pid="$(cat tmp/pids/server.pid)"
      if [ ! -z "$pid" ]; then
        echo "[OK] Process Id : ${pid}"
        kill -9 $pid
        echo "[OK] Process killed"
      else
        echo "[FAIL] Some issues in getting pid"
      fi
    }
    

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s