Merge pull request #2046 from dokku/2044_mh-support-inline-comments

strip inline comments from CHECKS and Procfile
This commit is contained in:
Michael Hobbs
2016-03-29 18:17:56 -07:00
5 changed files with 28 additions and 15 deletions

View File

@@ -20,13 +20,13 @@ dokku_deploy_cmd() {
local DOKKU_DEFAULT_DOCKER_ARGS=$(: | plugn trigger docker-args-deploy "$APP" "$IMAGE_TAG") local DOKKU_DEFAULT_DOCKER_ARGS=$(: | plugn trigger docker-args-deploy "$APP" "$IMAGE_TAG")
local DOKKU_IS_APP_PROXY_ENABLED="$(is_app_proxy_enabled "$APP")" local DOKKU_IS_APP_PROXY_ENABLED="$(is_app_proxy_enabled "$APP")"
local line local line; local PROC_TYPE; local PROC_COUNT; local CONTAINER_INDEX
while read -r line || [[ -n "$line" ]]; do while read -r line || [[ -n "$line" ]]; do
[[ "$line" =~ ^#.* ]] && continue [[ "$line" =~ ^#.* ]] && continue
local TRIM=${line%#*} line="$(strip_inline_comments "$line")"
local PROC_TYPE=${TRIM%%=*} PROC_TYPE=${line%%=*}
local PROC_COUNT=${TRIM#*=} PROC_COUNT=${line#*=}
local CONTAINER_INDEX=1 CONTAINER_INDEX=1
while [[ $CONTAINER_INDEX -le $PROC_COUNT ]]; do while [[ $CONTAINER_INDEX -le $PROC_COUNT ]]; do
local id=""; local port=""; local ipaddr="" local id=""; local port=""; local ipaddr=""

View File

@@ -125,13 +125,13 @@ checks_check_deploy() {
# Reads name/value pairs, sets the WAIT and TIMEOUT variables # Reads name/value pairs, sets the WAIT and TIMEOUT variables
exec < "$FILENAME" exec < "$FILENAME"
local LINE local line; local NAME; local VALUE
while read -r LINE; do while read -r line; do
line=$(strip_inline_comments "$line")
# Name/value pair # Name/value pair
if [[ "$LINE" =~ ^.+= ]]; then if [[ "$line" =~ ^.+= ]]; then
local TRIM=${LINE%#*} NAME=${TRIM%=*}
local NAME=${TRIM%=*} VALUE=${TRIM#*=}
local VALUE=${TRIM#*=}
[[ "$NAME" = "WAIT" ]] && local WAIT=$VALUE [[ "$NAME" = "WAIT" ]] && local WAIT=$VALUE
[[ "$NAME" = "TIMEOUT" ]] && local TIMEOUT=$VALUE [[ "$NAME" = "TIMEOUT" ]] && local TIMEOUT=$VALUE
[[ "$NAME" = "ATTEMPTS" ]] && local ATTEMPTS=$VALUE [[ "$NAME" = "ATTEMPTS" ]] && local ATTEMPTS=$VALUE

View File

@@ -311,16 +311,17 @@ get_app_running_container_ids() {
get_cmd_from_procfile() { get_cmd_from_procfile() {
declare desc="parse cmd from app Procfile" declare desc="parse cmd from app Procfile"
local APP=$1; local PROC_TYPE=$2; local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE" local APP=$1; local PROC_TYPE=$2; local DOKKU_PROCFILE="$DOKKU_ROOT/$APP/DOKKU_PROCFILE"
local name; local command;
verify_app_name "$APP" verify_app_name "$APP"
if [[ -f $DOKKU_PROCFILE ]]; then if [[ -f $DOKKU_PROCFILE ]]; then
local line; local name; local command
while read line || [[ -n "$line" ]]; do while read line || [[ -n "$line" ]]; do
if [[ -z "$line" ]] || [[ "$line" == "#"* ]]; then if [[ -z "$line" ]] || [[ "$line" == "#"* ]]; then
continue continue
fi fi
local name="${line%%:*}" line=$(strip_inline_comments "$line")
local command="${line#*:[[:space:]]}" name="${line%%:*}"
command="${line#*:[[:space:]]}"
[[ "$name" == "$PROC_TYPE" ]] && echo "$command" && break [[ "$name" == "$PROC_TYPE" ]] && echo "$command" && break
done < "$DOKKU_PROCFILE" done < "$DOKKU_PROCFILE"
fi fi
@@ -689,3 +690,11 @@ get_json_keys() {
cat | python -c 'import json,sys;obj=json.load(sys.stdin);print " ".join(obj'"${JSON_NODE}"'.keys())'; cat | python -c 'import json,sys;obj=json.load(sys.stdin);print " ".join(obj'"${JSON_NODE}"'.keys())';
fi fi
} }
strip_inline_comments() {
declare desc="removes bash-style comment from input line"
local line="$1"
local stripped_line="${line%[[:space:]]#*}"
echo "$stripped_line"
}

View File

@@ -1 +1,5 @@
WAIT=2 # wait 2 seconds
TIMEOUT=5 # set timeout to 5 seconds
ATTEMPTS=2 # try 2 times
/ nodejs/express / nodejs/express

View File

@@ -4,7 +4,7 @@
# Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job) # Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job)
cron: node worker.js cron: node worker.js
web: node web.js web: node web.js # testing inline comment
worker: node worker.js worker: node worker.js