subcommand restructure and bashstyle refactor. closes #1579

This commit is contained in:
Michael S. Hobbs
2016-03-01 13:26:35 -08:00
committed by Michael Hobbs
parent 76e27f0333
commit 89f289b433
105 changed files with 1969 additions and 1306 deletions

View File

@@ -3,6 +3,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
print_dokku_scale_file() {
local desc="prints contents of DOKKU_SCALE file"
local APP="$1"; local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
while read -r line || [[ -n "$line" ]]; do
dokku_log_info2_quiet "$line"
@@ -10,6 +11,7 @@ print_dokku_scale_file() {
}
extract_procfile() {
local desc="extracts procfile from app image"
local APP="$1"
local IMAGE_TAG="$(get_running_image_tag "$APP")"
local IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")"
@@ -25,6 +27,7 @@ extract_procfile() {
}
remove_procfile() {
local desc="removes DOKKU_PROCFILE"
local APP="$1"; local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
if [[ -f "$DOKKU_PROCFILE" ]]; then
rm -f "$DOKKU_PROCFILE"
@@ -32,6 +35,7 @@ remove_procfile() {
}
generate_scale_file() {
local desc="generates DOKKU_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 DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
verify_app_name "$APP"
@@ -64,6 +68,7 @@ generate_scale_file() {
}
set_scale() {
local desc="sets app proc type scaling"
local APP="$1"; local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"
shift 1
local SCALE_SETTINGS=("$@")
@@ -80,21 +85,8 @@ set_scale() {
done
}
ps_main() {
local APP="$1"; verify_app_name "$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
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 desc="starts app"
local APP="$1"; verify_app_name "$APP"
local IMAGE_TAG=$(get_running_image_tag "$APP");
@@ -108,6 +100,7 @@ ps_start() {
}
ps_stop() {
local desc="stops app"
local APP="$1"; verify_app_name "$APP"
local DOKKU_APP_RUNNING_CONTAINER_IDS=$(get_app_running_container_ids "$APP")
@@ -124,12 +117,14 @@ ps_stop() {
}
ps_rebuild() {
local desc="rebuilds app from base image"
local APP="$1"; verify_app_name "$APP"
plugn trigger receive-app "$APP"
}
ps_restart() {
local desc="restarts app"
local APP="$1"; verify_app_name "$APP"
local IMAGE_TAG=$(get_running_image_tag "$APP")
@@ -139,6 +134,7 @@ ps_restart() {
}
ps_scale() {
local desc="sets app scaling config according arguments; otherwise according to DOKKU_SCALE file"
local APP="$1"; verify_app_name "$APP"
local IMAGE_TAG=$(get_running_image_tag "$APP")
local DOKKU_SCALE_FILE="$DOKKU_ROOT/$APP/DOKKU_SCALE"