cleanup shellcheck SC2086
This commit is contained in:
committed by
Test Robot
parent
ff9bb2cbd7
commit
d1b87bd7b7
@@ -11,8 +11,8 @@ print_dokku_scale_file() {
|
||||
|
||||
extract_procfile() {
|
||||
local APP="$1"
|
||||
local IMAGE_TAG="$(get_running_image_tag $APP)"
|
||||
local IMAGE="$(get_app_image_name $APP $IMAGE_TAG)"
|
||||
local IMAGE_TAG="$(get_running_image_tag "$APP")"
|
||||
local IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")"
|
||||
local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
|
||||
verify_app_name "$APP"
|
||||
|
||||
@@ -32,7 +32,7 @@ remove_procfile() {
|
||||
}
|
||||
|
||||
generate_scale_file() {
|
||||
local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_app_image_name $APP $IMAGE_TAG); local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
local APP="$1"; local IMAGE_TAG="$2"; local IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG"); local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
|
||||
verify_app_name "$APP"
|
||||
|
||||
@@ -40,7 +40,7 @@ generate_scale_file() {
|
||||
if [[ ! -f $DOKKU_SCALE_FILE ]]; then
|
||||
dokku_log_info1_quiet "DOKKU_SCALE file not found in app image. Generating one based on Procfile..."
|
||||
|
||||
TMP_WORK_DIR=$(mktemp -d)
|
||||
TMP_WORK_DIR=$(mktemp -d -t "dokku_scale.XXXX")
|
||||
trap 'rm -rf "$TMP_WORK_DIR" > /dev/null' RETURN
|
||||
|
||||
if [[ -f $DOKKU_PROCFILE ]]; then
|
||||
@@ -51,16 +51,16 @@ generate_scale_file() {
|
||||
NAME=${line%%:*}
|
||||
NUM_PROCS=0
|
||||
[[ "$NAME" == "web" ]] && NUM_PROCS=1
|
||||
[[ -n "$NAME" ]] && echo "$NAME=$NUM_PROCS" >> $DOKKU_SCALE_FILE
|
||||
done < $DOKKU_PROCFILE
|
||||
[[ -n "$NAME" ]] && echo "$NAME=$NUM_PROCS" >> "$DOKKU_SCALE_FILE"
|
||||
done < "$DOKKU_PROCFILE"
|
||||
else
|
||||
echo "web=1" >> $DOKKU_SCALE_FILE
|
||||
echo "web=1" >> "$DOKKU_SCALE_FILE"
|
||||
fi
|
||||
dokku_log_info1_quiet "New DOKKU_SCALE file generated"
|
||||
else
|
||||
dokku_log_info1_quiet "DOKKU_SCALE file found ($DOKKU_SCALE_FILE)"
|
||||
fi
|
||||
print_dokku_scale_file $APP
|
||||
print_dokku_scale_file "$APP"
|
||||
}
|
||||
|
||||
set_scale() {
|
||||
@@ -72,34 +72,35 @@ set_scale() {
|
||||
PROC_COUNT=${procscale#*=}
|
||||
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
|
||||
sed --in-place "s:^${PROC_NAME}=.*:$PROC_NAME=$PROC_COUNT:g" $DOKKU_SCALE_FILE
|
||||
if (egrep -q ^${PROC_NAME}= "$DOKKU_SCALE_FILE" > /dev/null 2>&1); then
|
||||
sed --in-place "s:^${PROC_NAME}=.*:$PROC_NAME=$PROC_COUNT:g" "$DOKKU_SCALE_FILE"
|
||||
else
|
||||
echo "$PROC_NAME=$PROC_COUNT" >> $DOKKU_SCALE_FILE
|
||||
echo "$PROC_NAME=$PROC_COUNT" >> "$DOKKU_SCALE_FILE"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
ps_main() {
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
local DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP)
|
||||
local DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids "$APP")
|
||||
|
||||
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
|
||||
! (is_deployed "$APP") && echo "App $APP has not been deployed" && exit 0
|
||||
|
||||
for CID in $DOKKU_APP_RUNNING_CONTAINER_IDS; do
|
||||
has_tty && DOKKU_RUN_OPTS="-i -t"
|
||||
dokku_log_info1_quiet "running processes in container: $CID"
|
||||
# shellcheck disable=SC2086
|
||||
docker exec $DOKKU_RUN_OPTS $CID /bin/sh -c "ps auxwww"
|
||||
done
|
||||
}
|
||||
|
||||
ps_start() {
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
local IMAGE_TAG=$(get_running_image_tag $APP);
|
||||
local IMAGE_TAG=$(get_running_image_tag "$APP");
|
||||
|
||||
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
|
||||
! (is_deployed "$APP") && echo "App $APP has not been deployed" && exit 0
|
||||
|
||||
if ! (is_app_running $APP); then
|
||||
if ! (is_app_running "$APP"); then
|
||||
release_and_deploy "$APP" "$IMAGE_TAG"
|
||||
else
|
||||
echo "App $APP already running"
|
||||
@@ -108,14 +109,15 @@ ps_start() {
|
||||
|
||||
ps_stop() {
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
local DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids $APP)
|
||||
local DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids "$APP")
|
||||
|
||||
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
|
||||
! (is_deployed "$APP") && echo "App $APP has not been deployed" && exit 0
|
||||
|
||||
if [[ -n "$DOKKU_APP_RUNNING_CONTAINER_IDS" ]]; then
|
||||
echo "Stopping $APP ..."
|
||||
# shellcheck disable=SC2086
|
||||
docker stop $DOKKU_APP_RUNNING_CONTAINER_IDS > /dev/null || true
|
||||
plugn trigger post-stop $APP
|
||||
plugn trigger post-stop "$APP"
|
||||
else
|
||||
echo "App $APP already stopped"
|
||||
fi
|
||||
@@ -124,21 +126,21 @@ ps_stop() {
|
||||
ps_rebuild() {
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
|
||||
plugn trigger receive-app $APP
|
||||
plugn trigger receive-app "$APP"
|
||||
}
|
||||
|
||||
ps_restart() {
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
local IMAGE_TAG=$(get_running_image_tag $APP)
|
||||
local IMAGE_TAG=$(get_running_image_tag "$APP")
|
||||
|
||||
! (is_deployed $APP) && echo "App $APP has not been deployed" && exit 0
|
||||
! (is_deployed "$APP") && echo "App $APP has not been deployed" && exit 0
|
||||
|
||||
release_and_deploy "$APP" "$IMAGE_TAG"
|
||||
}
|
||||
|
||||
ps_scale() {
|
||||
local APP="$1"; verify_app_name "$APP"
|
||||
local IMAGE_TAG=$(get_running_image_tag $APP)
|
||||
local IMAGE_TAG=$(get_running_image_tag "$APP")
|
||||
local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
|
||||
shift 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user