Skip to content

Instantly share code, notes, and snippets.

@ahawkins
Created October 10, 2010 01:20
Show Gist options
  • Save ahawkins/618813 to your computer and use it in GitHub Desktop.
Save ahawkins/618813 to your computer and use it in GitHub Desktop.
namespace :specjour do
def specjour_dir
"~/.specjour/#{fetch(:project_name)}"
end
def specjour_pid_file
specjour_dir + "/manager.pid"
end
task :start, :roles => :test do
run "mkdir -p #{specjour_dir}"
run "mkdir -p #{project_path}"
run "cd #{project_path} ; screen -dmS specjour specjour ; true"
screens = capture "screen -ls ; true"
logger.info screens
match_data = screens.match /(\d+)\.specjour/
pid = match_data[1]
run "echo #{pid} > #{specjour_pid_file}"
end
task :stop, :roles => :test do
run %Q{if [ -f #{specjour_pid_file} ] ; then kill $(cat #{specjour_pid_file}) ; rm #{specjour_pid_file} ; screen -wipe ; fi ; true}
end
task :pid, :roles => :test do
pid = capture "echo #{specjour_pid_file}"
logger.info "PID: #{pid}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment