Merge pull request #3703 from plotly/update-scale-file-from-procfile
Update DOKKU_SCALE from Procfile during ps:scale
This commit is contained in:
3 files changed
+38
-3
No files matched your search
+11
-1
@@ -194,7 +194,17 @@ ps_scale() {
|
|||||||
local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
|
local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
|
||||||
shift 1
|
shift 1
|
||||||
|
|
||||||
[[ ! -e $DOKKU_SCALE_FILE ]] && generate_scale_file "$APP" "$IMAGE_TAG" >/dev/null 2>&1
|
# shellcheck disable=SC2015
|
||||||
|
[[ ! -e $DOKKU_PROCFILE ]] && extract_procfile "$APP" "$IMAGE_TAG" >/dev/null 2>&1 || true
|
||||||
|
if [[ ! -e $DOKKU_SCALE_FILE ]] ; then
|
||||||
|
generate_scale_file "$APP" "$IMAGE_TAG" >/dev/null 2>&1
|
||||||
|
elif [[ -e $DOKKU_PROCFILE ]] ; then
|
||||||
|
for PROC_NAME in $(procfile-util list --procfile "$DOKKU_PROCFILE"); do
|
||||||
|
if ! grep -qE "^${PROC_NAME}=" "$DOKKU_SCALE_FILE"; then
|
||||||
|
echo "$PROC_NAME=0" >> "$DOKKU_SCALE_FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
if [[ -z "$@" ]]; then
|
if [[ -z "$@" ]]; then
|
||||||
dokku_log_info1_quiet "Scaling for $APP"
|
dokku_log_info1_quiet "Scaling for $APP"
|
||||||
dokku_col_log_msg_quiet "proctype" "qty"
|
dokku_col_log_msg_quiet "proctype" "qty"
|
||||||
|
|||||||
@@ -41,6 +41,31 @@ EOF
|
|||||||
assert_output "node worker.js"
|
assert_output "node worker.js"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "(ps:scale) update DOKKU_SCALE from Procfile" {
|
||||||
|
local TMP=$(mktemp -d "/tmp/dokku.me.XXXXX")
|
||||||
|
trap 'popd &>/dev/null || true; rm -rf "$TMP"' INT TERM
|
||||||
|
|
||||||
|
CUSTOM_TMP="$TMP" deploy_app nodejs-express
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku --quiet ps:scale $TEST_APP"
|
||||||
|
output=$(echo "$output" | tr -s " ")
|
||||||
|
echo "output: ($output)"
|
||||||
|
assert_output $'cron: 0 \ncustom: 0 \nrelease: 0 \nweb: 1 \nworker: 0 '
|
||||||
|
|
||||||
|
pushd $TMP
|
||||||
|
echo scaletest: sleep infinity >> Procfile
|
||||||
|
git commit Procfile -m 'Add scaletest process'
|
||||||
|
git push target master:master
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku --quiet ps:scale $TEST_APP"
|
||||||
|
output=$(echo "$output" | tr -s " ")
|
||||||
|
echo "output: ($output)"
|
||||||
|
assert_output $'cron: 0 \ncustom: 0 \nrelease: 0 \nweb: 1 \nworker: 0 \nscaletest: 0 '
|
||||||
|
|
||||||
|
popd
|
||||||
|
rm -rf "$TMP"
|
||||||
|
}
|
||||||
|
|
||||||
@test "(ps:restart-policy) default policy" {
|
@test "(ps:restart-policy) default policy" {
|
||||||
run /bin/bash -c "dokku --quiet ps:restart-policy $TEST_APP"
|
run /bin/bash -c "dokku --quiet ps:restart-policy $TEST_APP"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ deploy_app() {
|
|||||||
local APP_TYPE=${APP_TYPE:="nodejs-express"}
|
local APP_TYPE=${APP_TYPE:="nodejs-express"}
|
||||||
local GIT_REMOTE=${GIT_REMOTE:="dokku@dokku.me:$TEST_APP"}
|
local GIT_REMOTE=${GIT_REMOTE:="dokku@dokku.me:$TEST_APP"}
|
||||||
local GIT_REMOTE_BRANCH=${GIT_REMOTE_BRANCH:="master"}
|
local GIT_REMOTE_BRANCH=${GIT_REMOTE_BRANCH:="master"}
|
||||||
local TMP=$(mktemp -d "/tmp/dokku.me.XXXXX")
|
local TMP=${CUSTOM_TMP:=$(mktemp -d "/tmp/dokku.me.XXXXX")}
|
||||||
|
|
||||||
rmdir "$TMP" && cp -r "${BATS_TEST_DIRNAME}/../../tests/apps/$APP_TYPE" "$TMP"
|
rmdir "$TMP" && cp -r "${BATS_TEST_DIRNAME}/../../tests/apps/$APP_TYPE" "$TMP"
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ deploy_app() {
|
|||||||
[[ -n "$CUSTOM_TEMPLATE" ]] && $CUSTOM_TEMPLATE $TEST_APP $TMP/$CUSTOM_PATH
|
[[ -n "$CUSTOM_TEMPLATE" ]] && $CUSTOM_TEMPLATE $TEST_APP $TMP/$CUSTOM_PATH
|
||||||
|
|
||||||
pushd "$TMP" &>/dev/null || exit 1
|
pushd "$TMP" &>/dev/null || exit 1
|
||||||
trap 'popd &>/dev/null || true; rm -rf "$TMP"' RETURN INT TERM
|
[[ -z "$CUSTOM_TMP" ]] && trap 'popd &>/dev/null || true; rm -rf "$TMP"' RETURN INT TERM
|
||||||
|
|
||||||
git init
|
git init
|
||||||
git config user.email "robot@example.com"
|
git config user.email "robot@example.com"
|
||||||
|
|||||||
Reference in new issue
Block a user