Skip to content
Browse files

Added rollback

  • Loading branch information...
1 parent b841c72 commit 34c7e41bb4085c5083eeb60632423f512557a269 @wayneeseguin wayneeseguin committed Jan 5, 2010
Showing with 26 additions and 2 deletions.
  1. +3 −1 scripts/initialize
  2. +22 −0 services/bdsm/rollback
  3. 0 services/bdsm/update
  4. +1 −1 services/unicorn/stop
View
4 scripts/initialize
@@ -22,11 +22,13 @@ export keep_releases=${keep_releases:-"4"}
export timestamp="$(date +%m.%d.%Y-%H:%M:%S)"
export project_path="${project_path:-$HOME}"
export shared_path="${shared_path:-$project_path/shared}"
+export previous_path="${previous_path:-$project_path/previous}"
export current_path="${current_path:-$project_path/current}"
+export discarded_path="${discarded_path:-$project_path/discard}"
export RAILS_ENV="${RAILS_ENV:-"production"}"
+export user=$(whoami)
result=0
-user=$(whoami)
if [[ -d "$project_path/previous" ]] ; then
old_releases="$(cd $project_path/previous && ls -t | awk "NR > $keep_releases { print \$0 }")"
View
22 services/bdsm/rollback
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+if [[ "$trace_flag" -eq 1 ]] ; then set -x ; fi
+
+mkdir -p "$previous_path" "$discarded_path"
+
+previous="$(ls "$previous_path"/* | sort)"
+if [[ -d "$previous" ]] ; then
+ $scripts_path/log "info" "info" "discarding current to $discarded_path/$timestamp ..."
+ mv "$current_path" "$discarded_path/$timestamp"
+
+ $scripts_path/log "info" "info" "Rolling back to $previous ..."
+ mv "$previous" "${current_path%/}"
+else
+ $scripts_path/log "error" "info" "Previous release was not found in $previous_path/"
+fi
+result=$?
+
+$scripts_path/log "info" "info" "Rolled back to $previous."
+
+exit $result
+
View
0 services/bdsm/update 100644 → 100755
File mode changed.
View
2 services/unicorn/stop
@@ -4,7 +4,7 @@ if [[ ! -z "$HOME/.bashrc" ]] ; then source "$HOME/.bashrc" ; fi
if [[ "$trace_flag" -eq 1 ]] ; then set -x ; fi
-master_pid="$(ps auxww | grep '[u]nicorn' | grep 'master' | awk '/'${project}'/{print $2}')"
+master_pid="$(ps auxww | grep '[u]nicorn' | grep 'master' | awk '/'${user}'/{print $2}')"
cd $current_path
if [[ -s ".rvmrc" ]] ; then source ".rvmrc" ; fi

0 comments on commit 34c7e41

Please sign in to comment.
Something went wrong with that request. Please try again.