implement central deploy lock and use in tar plugin

This commit is contained in:
Michael Hobbs
2016-06-17 15:25:46 -07:00
parent 2ece0e1bf8
commit 4f8c1b64c9
5 changed files with 45 additions and 40 deletions

View File

@@ -2,26 +2,10 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
tar_build_cmd() {
declare desc="calls tar:build-locked via command line"
local cmd="tar:build"
verify_app_name "$2"
local APP="$2"; local APP_BUILD_LOCK="$DOKKU_ROOT/$APP/.build.lock"
local 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" tar_build_locked_cmd "tar:build-locked" "$@"
}
tar_build_locked_cmd() {
tar_build() {
declare desc="builds apps from tarball via command line"
local cmd="tar:build-locked"
local APP="$2"
verify_app_name "$2"
shift 2
local APP="$1"; verify_app_name "$APP"
shift 1
# clean up after ourselves
local TAR_BUILD_TMP_WORK_DIR=$(mktemp -d "/tmp/dokku_tar.XXXX")
@@ -49,16 +33,6 @@ tar_build_locked_cmd() {
fi
}
tar_from_cmd() {
declare desc="deploys app from tarball at URL via command line"
local cmd="tar:from"
verify_app_name "$2"
local APP=$2
local URL=$3
shift 3
curl -# --insecure -L "$URL" | tar_in_cmd "tar:in" "$APP" "$@"
}
tar_in_cmd() {
declare desc="deploys app from tarball on STDIN via command line"
local cmd="tar:in"
@@ -68,3 +42,13 @@ tar_in_cmd() {
tee "$DOKKU_ROOT/$APP/src.tar" | wc -c
plugn trigger receive-app "$APP"
}
tar_from_cmd() {
declare desc="deploys app from tarball at URL via command line"
local cmd="tar:from"
verify_app_name "$2"
local APP=$2
local URL=$3
shift 3
curl -# --insecure -L "$URL" | tar_in_cmd "tar:in" "$APP" "$@"
}