How to stop a Daemon Server in Rails?
ruby-on-rails, ubuntu
Solution
How about a rake task?
desc 'stop rails'
task :stop do
pid_file = 'tmp/pids/server.pid'
pid = File.read(pid_file).to_i
Process.kill 9, pid
File.delete pid_file
end
run with rake stop or sudo rake stop
Problem
I am running my rails application using the following ``` $script/server -d webrick ``` on my Ubuntu system , above command run the webrick server in background . I could kill the process using kill command ``` $kill pid ``` Does rails provide any command to stop the background running daemon server ? like the one provided by rails to start the server , Thanks . EDIT When it is appropriate to start the daemon server ? Any real time scenario will help Thanks