use flock when (re)building/deploying

This commit is contained in:
Michael Hobbs committed 2015-01-28 16:18:57 -08:00
1 parent ef369eb02f
commit c96d139f54
2 files changed
+18 -4

No files matched your search

+17 -3
View File
@@ -25,7 +25,7 @@ case "$1" in
# Only run this script for the master branch. You can remove this # Only run this script for the master branch. You can remove this
# if block if you wish to run it for others as well. # if block if you wish to run it for others as well.
if [[ $refname = "refs/heads/master" ]] ; then if [[ $refname = "refs/heads/master" ]] ; then
git_archive_all $APP $newrev | dokku receive $APP | sed -u "s/^/"$'\e[1G'"/" dokku git-build $APP $newrev
else else
echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to master." echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to master."
echo $'\e[1G\e[K'"-----> for example, try 'git push <dokku> ${refname/refs\/heads\/}:master'" echo $'\e[1G\e[K'"-----> for example, try 'git push <dokku> ${refname/refs\/heads\/}:master'"
@@ -40,8 +40,22 @@ case "$1" in
pluginhook git-post-pull $APP pluginhook git-post-pull $APP
;; ;;
git-rebuild) git-build)
APP="$2"; REF=$(< "$DOKKU_ROOT/$APP/refs/heads/master") APP="$2"; APP_BUILD_LOCK="$DOKKU_ROOT/$APP/.build.lock"
APP_BUILD_LOCK_MSG="$APP is currently being deployed or locked. Waiting..."
[[ $(flock -n "$APP_BUILD_LOCK" true &>/dev/null ; echo $?) -ne 0 ]] && echo "$APP_BUILD_LOCK_MSG"
shift 1
flock -o "$APP_BUILD_LOCK" dokku git-build-locked "$@"
;;
git-build-locked)
APP="$2"
if [[ $# -ge 3 ]];then
REF="$3"
else
REF=$(< "$DOKKU_ROOT/$APP/refs/heads/master")
fi
git_archive_all $APP $REF | dokku receive $APP | sed -u "s/^/"$'\e[1G'"/" git_archive_all $APP $REF | dokku receive $APP | sed -u "s/^/"$'\e[1G'"/"
;; ;;
+1 -1
View File
@@ -61,7 +61,7 @@ case "$1" in
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1 [[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
APP="$2" APP="$2"
dokku git-rebuild $APP dokku git-build $APP
;; ;;
ps:rebuildall) ps:rebuildall)