How to kill rails webrick server?

When I try to start the server through rails s , I get the following error message:

 C:\Users\Frankie\Documents\stocktracker>rails s => Booting WEBrick => Rails 3.2.8 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server A server is already running. Check C:/Users/Frankie/Documents/stocktracker/tmp/p ids/server.pid. Exiting 

The number specified in server.pid is 8436.

How do I manually kill this process? How can I easily kill all webrick servers now?

+7
source share
5 answers

You can use the taskkill utility.

 taskkill /PID 8436 
+11
source

If you are using iTerm2 on OSX, you can open Toolbelt => ShowToolbelt, select ruby ​​pid 8436 and press the send signal button to kill it. Sometimes killing a task does not work for me.

Alternatively, you can ps -aux | grep rails ps -aux | grep rails find pid. and then kill as other answers recommend.

+1
source

The following task definition works for me (put it in the * .rake file in the lib \ tasks folder):

 namespace :server do # --------------------------------------------------------------------------- desc "Clear the previous server instance clutter." task :cleanup => :environment do pidfile = 'tmp/pids/server.pid' if File.exists? pidfile pid = File.read(pidfile).to_i if RbConfig::CONFIG['host_os'] =~ /mswin32/ sh "taskkill /f /pid #{pid}" sh "del tmp\\pids\\server.pid" else sh "kill #{pid}" sh "rm #{pidfile}" end puts "All cleaned up. Yay!" else puts "Already clean. Whew!" end end # --------------------------------------------------------------------------- desc "Start an instance of the server cleanly." task :startup => :cleanup do sh "rails server" end # --------------------------------------------------------------------------- end 

Now just run

 rake server:startup 

It cleans up all remaining processes and pid files on Windoze before attempting to start the rails server again.

0
source

For Linux/Ubuntu Users ubuntu has a kill command. When the webrick server webrick in the project directory in the directory APP_DIR/tmp/pids/server.pid all process identifiers will be saved.
You just need to open the file, you will find the process ID of the current server. Now you can use the following command to kill the process

 $ kill [pid] # Example kill 8123 
0
source

Follow these steps:

1.Find 'rails s' process id: ps -aux | grep rails

2. Use the kill command with the -9 parameter as: kill -p [PID]

You will not be disappointed.

-2
source

All Articles