Created
September 3, 2013 06:44
-
-
Save victorcreed/6420403 to your computer and use it in GitHub Desktop.
automating restart server task for demonized rails server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :vf do | |
namespace :server do | |
desc "stop server" | |
task :stop => :environment do | |
puts "-----------------Stoping Server----------------" | |
pid_file = "tmp/pids/server.pid" | |
pid = File.read(pid_file).to_i | |
puts "************pid = #{pid}" | |
Process.kill 9, pid | |
File.delete pid_file | |
puts "-----------------Server Stopped----------------" | |
end | |
desc "start server" | |
task :start => :environment do | |
puts "-----------------Starting Server----------------" | |
`bundle exec rails s -d` | |
puts "-----------------Server Started----------------" | |
end | |
desc "start server" | |
task :restart => :environment do | |
puts "-----------------Restarting Server----------------" | |
Rake::Task["vf:server:stop"].invoke rescue puts "server is already stopped" | |
Rake::Task["vf:server:start"].invoke rescue puts "server is already running" | |
puts "-----------------Server Restarted----------------" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment