refactor to explicitly set IMAGE via get_app_image_name()

This commit is contained in:
Michael Hobbs
2015-09-03 16:07:23 -07:00
parent 2f16b06a76
commit 495b1d2ba0
14 changed files with 122 additions and 107 deletions

View File

@@ -18,11 +18,13 @@ case "$1" in
ps:start)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
APP="$2"; TAG=$(get_running_image_tag "$APP"); verify_app_name "$APP" "$TAG"
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP);
verify_app_name "$APP"
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
if ! (is_app_running $APP); then
release_and_deploy "$APP" "$TAG"
release_and_deploy "$APP" "$IMAGE_TAG"
else
echo "App $APP already running"
fi
@@ -30,7 +32,9 @@ case "$1" in
ps:stop)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
APP="$2"; verify_app_name "$APP"; DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP)
APP="$2"; DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP)
verify_app_name "$APP"
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
if [[ -n "$DOKKU_APP_RUNNING_CONTAINER_IDS" ]]; then
@@ -60,10 +64,12 @@ case "$1" in
ps:restart)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
APP="$2"; TAG=$(get_running_image_tag $APP); verify_app_name "$APP" "$TAG"
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP)
verify_app_name "$APP"
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
release_and_deploy "$APP" "$TAG"
release_and_deploy "$APP" "$IMAGE_TAG"
;;
ps:restartall)
@@ -78,18 +84,19 @@ case "$1" in
ps:scale)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
APP="$2"; TAG=$(get_running_image_tag "$APP"); verify_app_name "$APP" "$TAG"
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP)
verify_app_name "$APP"
DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
shift 2
generate_scale_file "$APP" "$TAG"
generate_scale_file "$APP" "$IMAGE_TAG"
if [[ -z "$@" ]];then
dokku_log_info1 "Scaling for $APP"
dokku_log_info2 "$(< $DOKKU_SCALE_FILE)"
else
set_scale "$APP" "$@"
release_and_deploy "$APP" "$TAG"
release_and_deploy "$APP" "$IMAGE_TAG"
fi
;;

View File

@@ -11,8 +11,9 @@ print_dokku_scale_file(){
}
generate_scale_file() {
local APP="$1"; local TAG="$3"; local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
verify_app_name "$APP" "$TAG"
local APP="$1"; local IMAGE_TAG="$3"; local IMAGE=$(get_app_image_name $APP $IMAGE_TAG); local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
verify_app_name "$APP"
copy_from_image "$IMAGE" "/app/DOKKU_SCALE" "$DOKKU_ROOT/$APP" 2>/dev/null || true
if [[ ! -f $DOKKU_SCALE_FILE ]]; then
dokku_log_info1_quiet "DOKKU_SCALE file not found in app image. Defaulting to a single web process"