more style/function tweaks

This commit is contained in:
Michael Hobbs
2016-03-02 10:50:09 -08:00
committed by Michael Hobbs
parent 89f289b433
commit aa2415eeb8
40 changed files with 702 additions and 531 deletions

View File

@@ -44,7 +44,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 -t "dokku_scale.XXXX")
local TMP_WORK_DIR=$(mktemp -d -t "dokku_scale.XXXX")
trap 'rm -rf "$TMP_WORK_DIR" > /dev/null' RETURN
if [[ -f $DOKKU_PROCFILE ]]; then
@@ -52,8 +52,8 @@ generate_scale_file() {
if [[ -z "$line" ]] || [[ "$line" == "#"* ]]; then
continue
fi
NAME=${line%%:*}
NUM_PROCS=0
local NAME=${line%%:*}
local NUM_PROCS=0
[[ "$NAME" == "web" ]] && NUM_PROCS=1
[[ -n "$NAME" ]] && echo "$NAME=$NUM_PROCS" >> "$DOKKU_SCALE_FILE"
done < "$DOKKU_PROCFILE"
@@ -73,8 +73,8 @@ set_scale() {
shift 1
local SCALE_SETTINGS=("$@")
for procscale in "${SCALE_SETTINGS[@]}"; do
PROC_NAME=${procscale%%=*}
PROC_COUNT=${procscale#*=}
local PROC_NAME=${procscale%%=*}
local 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
@@ -147,8 +147,8 @@ ps_scale() {
dokku_col_log_info1_quiet "--------" "---"
while read -r line || [[ -n "$line" ]]; do
[[ -z "$line" ]] && continue
PROC_NAME=${line%%=*}
PROC_COUNT=${line#*=}
local PROC_NAME=${line%%=*}
local PROC_COUNT=${line#*=}
dokku_col_log_info1 "$PROC_NAME" "$PROC_COUNT"
done < "$DOKKU_SCALE_FILE"
else

View File

@@ -1,9 +1,16 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
APP="$1"
ps_post_deploy() {
local desc="ps post-deploy plugin trigger"
local trigger="ps_post_deploy"
local APP="$1"
remove_procfile "$APP"
dokku config:set --no-restart "$APP" DOKKU_APP_RESTORE=1
remove_procfile "$APP"
config_set --no-restart "$APP" DOKKU_APP_RESTORE=1
}
ps_post_deploy "$@"

View File

@@ -1,8 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
APP="$1"
ps_post_stop() {
local desc="ps post-stop plugin trigger"
local trigger="ps_post_stop"
local APP="$1"
dokku config:set --no-restart "$APP" DOKKU_APP_RESTORE=0
config_set --no-restart "$APP" DOKKU_APP_RESTORE=0
}

View File

@@ -3,7 +3,13 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
APP="$1"
ps_pre_deploy() {
local desc="ps pre-deploy plugin trigger"
local trigger="ps_pre_deploy"
local APP="$1"
extract_procfile "$APP"
generate_scale_file "$APP"
extract_procfile "$APP"
generate_scale_file "$APP"
}
ps_pre_deploy "$@"

View File

@@ -12,8 +12,9 @@ ps_main_cmd() {
! (is_deployed "$APP") && echo "App $APP has not been deployed" && exit 0
local CID
for CID in $DOKKU_APP_RUNNING_CONTAINER_IDS; do
has_tty && DOKKU_RUN_OPTS="-i -t"
has_tty && local 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"

View File

@@ -1,13 +1,14 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
ps_restore_cmd() {
local desc="starts all apps with DOKKU_APP_RESTORE not set to 0 via command line"
local cmd="ps:restore"
for app in $(dokku_apps); do
local DOKKU_APP_RESTORE=$(dokku config:get "$app" DOKKU_APP_RESTORE || true)
local DOKKU_APP_RESTORE=$(config_get "$app" DOKKU_APP_RESTORE || true)
if [[ $DOKKU_APP_RESTORE != 0 ]]; then
echo "Restoring app $app ..."
ps_start "$app"