Created
May 12, 2012 17:32
-
-
Save ifesdjeen/2667797 to your computer and use it in GitHub Desktop.
Capistrano deployment
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/sh | |
PATH=/bin:/usr/bin:/sbin:/usr/sbin | |
DAEMON=/a/my-app/current/run.sh | |
PIDDIR=/a/my-app/current/tmp/pids | |
PIDFILE="$PIDDIR/my-app.pid" | |
USER="myuser" | |
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" | |
if [ ! -d $PIDDIR ]; then | |
mkdir $PIDDIR | |
chown $USER.$USER $PIDDIR | |
fi | |
case "$1" in | |
start) | |
start-stop-daemon --start --quiet --oknodo --background --pidfile $PIDFILE --exec $DAEMON --chuid $USER -- $SERVICES_OPTS | |
sleep 5 | |
$0 status | |
;; | |
stop) | |
if start-stop-daemon --stop --quiet --pidfile $PIDFILE; then | |
exit 0 | |
else | |
exit 1 | |
fi | |
;; | |
esac |
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
set :stages, %w(dev qa staging production) | |
set :default_stage, "dev" |
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 | |
MY_APP_HOME="/applications/my-application/current" | |
MY_APP_JAR="target/my-application-0.1.0-SNAPSHOT-standalone.jar" | |
java -Xms512m -Xmx1024m -jar $MY_APP_HOME/$MY_APP_JAR --config $MY_APP_HOME/config/production.clj & | |
echo $! > $MY_APP_HOME/tmp/pids/my-application.pid | |
exit 0 |
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
(ns my-application.server | |
(:gen-class)) | |
(defn -main | |
[& args] | |
(run!)) |
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
server "username@ec2-111-111-111-111.eu-west-1.compute.amazonaws.com", :app, :primary => true | |
server "username@ec2-111-111-111-112.eu-west-1.compute.amazonaws.com", :app | |
server "username@ec2-111-111-111-113.eu-west-1.compute.amazonaws.com", :db | |
server "username@ec2-111-111-111-114.eu-west-1.compute.amazonaws.com", :web |
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
task :start do | |
deploy.start_master | |
deploy.start_slave | |
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
task :start_master, :only => { :primary => true } do | |
run "APP_MODE=master #{current_release}/script/initscript.sh start" | |
end | |
task :start_slave do | |
run "APP_MODE=slave #{current_release}/script/initscript.sh start" | |
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
namespace :deploy do | |
task :restart do | |
deploy.restart_app | |
deploy.restart_db | |
deploy.restart_web | |
end | |
task :restart_app, :roles => :app do | |
# handle app restart | |
end | |
task :restart_db, :roles => :db do | |
# handle db restart | |
end | |
task :restart_web, :roles => :web do | |
# handle web restart | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment