Skip to content

Instantly share code, notes, and snippets.

@eskim
Forked from jeroenr/config.rb
Created August 15, 2012 07:54
Show Gist options
  • Save eskim/3357462 to your computer and use it in GitHub Desktop.
Save eskim/3357462 to your computer and use it in GitHub Desktop.
Capistrano deployment script for play2 application
namespace :deploy do
task :restart do
stop
sleep 1
start
end
task :start do
targets = find_servers_for_task(current_task)
failed_targets = targets.map do |target|
cmd = "ssh #{user}@#{target.host} 'cd #{current_release}/my-app && ./start.sh'"
target.host unless system cmd
end.compact
raise "starting my play2 app failed on #{failed_targets.join(',')}" if failed_targets.any?
end
task :stop do
targets = find_servers_for_task(current_task)
failed_targets = targets.map do |target|
cmd = "ssh #{user}@#{target.host} 'cd #{current_release}/my-app && ./stop.sh'"
target.host unless system cmd
end.compact
raise "stopping my play2 app failed on #{failed_targets.join(',')}" if failed_targets.any?
end
end
#!/bin/bash
nohup bash -c "/var/lib/play2/play start &>> /tmp/my-app.log 2>&1" &> /dev/null &
#!/bin/bash
pid=`cat RUNNING_PID 2> /dev/null`
if [ "$pid" == "" ]; then echo "my play2 app is not running"; exit 0; fi
echo "Stopping my play2 app..."
kill -SIGTERM $pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment