Created
May 14, 2012 15:17
-
-
Save jeroenr/2694531 to your computer and use it in GitHub Desktop.
Capistrano deployment script for play2 application
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 :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 |
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
#!/bin/bash | |
nohup bash -c "/var/lib/play2/play start &>> /tmp/my-app.log 2>&1" &> /dev/null & |
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
#!/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 |
why do you need so many levels deep? why can't we do play start &
or maybe just nohup play start &
? why make it append to a log, background it using & and then put it in bash and background bash itself??
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much for these two scripts! Finally got this working because of them!