Created
December 1, 2009 10:28
-
-
Save scottwb/246209 to your computer and use it in GitHub Desktop.
Script to kill Rails script/server processes.
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
#!/usr/bin/env ruby | |
# | |
# Quick-and-dirty script to kill rogue script/server processes. | |
# | |
############################################################################### | |
# Configuration | |
############################################################################### | |
# The command you use to run your Rails server. | |
SERVER_CMD="ruby script/server -e production" | |
############################################################################### | |
# Main Program | |
############################################################################### | |
username = ENV['USER'] | |
killed = false | |
`ps auxwww | grep "ruby"`.split(/$/).grep(/^#{username}\s+(\d+)\s+.*#{SERVER_CMD.gsub('/','\\/')}/) do |line| | |
puts "Killing PID: #{$1}" | |
system("kill -9 #{$1}") | |
killed = true | |
end | |
if !killed | |
puts "No script/server processes to kill." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment