feat: verify that a process exists before scaling it
Refs #2582 Refs #3196
This commit is contained in:
@@ -74,12 +74,18 @@ generate_scale_file() {
|
||||
|
||||
set_scale() {
|
||||
declare desc="sets app proc type scaling"
|
||||
local APP="$1"; local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
declare APP="$1"
|
||||
local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
|
||||
shift 1
|
||||
|
||||
local SCALE_SETTINGS=("$@")
|
||||
for procscale in "${SCALE_SETTINGS[@]}"; do
|
||||
local PROC_NAME=${procscale%%=*}
|
||||
local PROC_COUNT=${procscale#*=}
|
||||
if [[ -f "$DOKKU_PROCFILE" ]] && ! procfile-util exists --procfile "$DOKKU_PROCFILE" --process-type "$PROC_NAME" > /dev/null 2>&1; then
|
||||
dokku_log_fail "${PROC_NAME} is not a valid process name"
|
||||
fi
|
||||
is_number "$PROC_COUNT" || dokku_log_fail "ps:scale $PROC_COUNT is not a number"
|
||||
dokku_log_info1_quiet "Scaling $APP:$PROC_NAME to $PROC_COUNT"
|
||||
if (egrep -q "^${PROC_NAME}=" "$DOKKU_SCALE_FILE" > /dev/null 2>&1); then
|
||||
@@ -151,6 +157,7 @@ ps_scale() {
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
local IMAGE_TAG=$(get_running_image_tag "$APP")
|
||||
local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
|
||||
shift 1
|
||||
|
||||
[[ ! -e $DOKKU_SCALE_FILE ]] && generate_scale_file "$APP" "$IMAGE_TAG"
|
||||
|
||||
@@ -70,6 +70,13 @@ teardown() {
|
||||
done
|
||||
}
|
||||
|
||||
@test "(ps:scale) dockerfile" {
|
||||
run bash -c "dokku ps:scale $TEST_APP non-existent=2"
|
||||
echo "output: "$output
|
||||
echo "status: "$status
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "(ps:scale) dockerfile" {
|
||||
run bash -c "dokku ps:scale $TEST_APP web=2"
|
||||
echo "output: "$output
|
||||
|
||||
Reference in New Issue
Block a user