Skip to content

Instantly share code, notes, and snippets.

@brynary
Created November 19, 2008 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brynary/26424 to your computer and use it in GitHub Desktop.
Save brynary/26424 to your computer and use it in GitHub Desktop.
namespace :selenium do
namespace :app_server do
desc "Start a mongrel for the selenium environment on port 3001"
task :start do
rails_root = File.expand_path(File.dirname(__FILE__) + "/../..")
pid_file = File.expand_path(rails_root + "/tmp/pids/mongrel_selenium.pid")
system "cd #{rails_root}; mongrel_rails start -d -e selenium -p 3001 -c #{rails_root} --pid #{pid_file}"
end
desc "Start or restart a mongrel for the selenium environment on port 3001"
task :restart do
rails_root = File.expand_path(File.dirname(__FILE__) + "/../..")
pid_file = File.expand_path(rails_root + "/tmp/pids/mongrel_selenium.pid")
running = false
if File.exists?(pid_file) && (pid = open(pid_file).read.to_i)
begin
Process::kill 0, pid
running = true
rescue Errno::ESRCH, Errno::EPERM
end
end
if running
system "cd #{rails_root}; mongrel_rails restart -c #{rails_root} --pid #{pid_file}"
else
system "cd #{rails_root}; mongrel_rails start -d -e selenium -p 3001 -c #{rails_root} --pid #{pid_file}"
end
end
desc "Stop a mongrel for the selenium environment on port 3001"
task :stop do
rails_root = File.expand_path(File.dirname(__FILE__) + "/../..")
pid_file = File.expand_path(rails_root + "/tmp/pids/mongrel_selenium.pid")
system "cd #{rails_root}; mongrel_rails stop -c #{rails_root} --pid #{pid_file}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment