rename log functions with dokku_log_ prefix

This commit is contained in:
Michael Hobbs committed 2015-02-06 08:28:14 -08:00
1 parent 371ba99540
commit 9164740117
9 files changed
+45 -45

No files matched your search

+10 -10
View File
@@ -42,15 +42,15 @@ fi
case "$1" in case "$1" in
receive) receive)
APP="$2"; IMAGE="dokku/$APP" APP="$2"; IMAGE="dokku/$APP"
info1 "Cleaning up ..." dokku_log_info1 "Cleaning up ..."
dokku cleanup dokku cleanup
info1 "Building $APP ..." dokku_log_info1 "Building $APP ..."
cat | dokku build $APP cat | dokku build $APP
info1 "Releasing $APP ..." dokku_log_info1 "Releasing $APP ..."
dokku release $APP dokku release $APP
info1 "Deploying $APP ..." dokku_log_info1 "Deploying $APP ..."
dokku deploy $APP dokku deploy $APP
info2 "Application deployed:" dokku_log_info2 "Application deployed:"
dokku urls $APP | sed "s/^/ /" dokku urls $APP | sed "s/^/ /"
echo echo
;; ;;
@@ -124,7 +124,7 @@ case "$1" in
# run checks first, then post-deploy hooks, which switches Nginx traffic # run checks first, then post-deploy hooks, which switches Nginx traffic
trap kill_new INT TERM EXIT trap kill_new INT TERM EXIT
info1 "Running pre-flight checks" dokku_log_info1 "Running pre-flight checks"
pluginhook check-deploy $id $APP $port ${ipaddr:-localhost} pluginhook check-deploy $id $APP $port ${ipaddr:-localhost}
# now using the new container # now using the new container
@@ -132,7 +132,7 @@ case "$1" in
echo $port > "$DOKKU_ROOT/$APP/PORT" echo $port > "$DOKKU_ROOT/$APP/PORT"
echo "http://$(< "$DOKKU_ROOT/HOSTNAME"):$port" > "$DOKKU_ROOT/$APP/URL" echo "http://$(< "$DOKKU_ROOT/HOSTNAME"):$port" > "$DOKKU_ROOT/$APP/URL"
info1 "Running post-deploy" dokku_log_info1 "Running post-deploy"
pluginhook post-deploy $APP $port $ipaddr pluginhook post-deploy $APP $port $ipaddr
trap - INT TERM EXIT trap - INT TERM EXIT
@@ -140,7 +140,7 @@ case "$1" in
if [[ -n "$oldid" ]]; then if [[ -n "$oldid" ]]; then
# Let the old container finish processing requests, before terminating it # Let the old container finish processing requests, before terminating it
WAIT="${DOKKU_WAIT_TO_RETIRE:-60}" WAIT="${DOKKU_WAIT_TO_RETIRE:-60}"
info1 "Shutting down old container in $WAIT seconds" dokku_log_info1 "Shutting down old container in $WAIT seconds"
( (
exec >/dev/null 2>/dev/null </dev/null exec >/dev/null 2>/dev/null </dev/null
trap '' INT HUP trap '' INT HUP
@@ -211,8 +211,8 @@ EOF
done done
if [ "$implemented" -eq 0 ]; then if [ "$implemented" -eq 0 ]; then
warn "\`$*\` is not a dokku command." dokku_log_warn "\`$*\` is not a dokku command."
warn "See \`dokku help\` for a list of available commands." dokku_log_warn "See \`dokku help\` for a list of available commands."
exit 1 exit 1
fi fi
;; ;;
+6 -6
View File
@@ -4,13 +4,13 @@ source "$(dirname $0)/../common/functions"
case "$1" in case "$1" in
apps) apps)
info2 "My Apps" dokku_log_info2_quiet "My Apps"
find $DOKKU_ROOT -follow -maxdepth 1 -type d \( ! -iname ".*" \) -not -path $DOKKU_ROOT/tls | sed 's|^\./||g' | sed 's|'$DOKKU_ROOT'\/||' | tail -n +2 | sort find $DOKKU_ROOT -follow -maxdepth 1 -type d \( ! -iname ".*" \) -not -path $DOKKU_ROOT/tls | sed 's|^\./||g' | sed 's|'$DOKKU_ROOT'\/||' | tail -n +2 | sort
;; ;;
apps:create) apps:create)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1 [[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ -d "$DOKKU_ROOT/$2" ]] && warn "Name is already taken" && exit 1 [[ -d "$DOKKU_ROOT/$2" ]] && dokku_log_warn "Name is already taken" && exit 1
APP="$2" APP="$2"
mkdir -p "$DOKKU_ROOT/$APP" mkdir -p "$DOKKU_ROOT/$APP"
@@ -25,14 +25,14 @@ case "$1" in
[[ "$3" == "force" ]] && DOKKU_APPS_FORCE_DELETE=1 [[ "$3" == "force" ]] && DOKKU_APPS_FORCE_DELETE=1
if [[ -z "$DOKKU_APPS_FORCE_DELETE" ]]; then if [[ -z "$DOKKU_APPS_FORCE_DELETE" ]]; then
warn "WARNING: Potentially Destructive Action" dokku_log_warn "WARNING: Potentially Destructive Action"
warn "This command will destroy $APP (including all add-ons)." dokku_log_warn "This command will destroy $APP (including all add-ons)."
warn "To proceed, type \"$APP\"" dokku_log_warn "To proceed, type \"$APP\""
echo "" echo ""
read -p "> " app_name read -p "> " app_name
if [[ "$app_name" != "$APP" ]]; then if [[ "$app_name" != "$APP" ]]; then
warn "Confirmation did not match $APP. Aborted." dokku_log_warn "Confirmation did not match $APP. Aborted."
exit 1 exit 1
fi fi
fi fi
+1 -1
View File
@@ -18,7 +18,7 @@ if [[ -f "$DOKKU_ROOT/$APP/ENV" ]]; then
fi fi
if [[ ! -z "$BUILD_ENV" ]]; then if [[ ! -z "$BUILD_ENV" ]]; then
info1 "Adding BUILD_ENV to build environment..." dokku_log_info1 "Adding BUILD_ENV to build environment..."
# create build env files for use in buildpacks like this: # create build env files for use in buildpacks like this:
# https://github.com/niteoweb/heroku-buildpack-buildout/blob/5879fa3418f7d8e079f1aa5816ba1adde73f4948/bin/compile#L34 # https://github.com/niteoweb/heroku-buildpack-buildout/blob/5879fa3418f7d8e079f1aa5816ba1adde73f4948/bin/compile#L34
id=$(echo $BUILD_ENV |sed 's@export @@g'| docker run -i -a stdin $IMAGE /bin/bash -c "for ENV_VAR in $(cat); do echo \$ENV_VAR |sed 's@^\([^=]*\)=\(.*\)\$@echo \\\"\2\\\" >/tmp/env/\1@g' >>/tmp/set_env.sh; done && mkdir -p /tmp/env && /bin/bash /tmp/set_env.sh") id=$(echo $BUILD_ENV |sed 's@export @@g'| docker run -i -a stdin $IMAGE /bin/bash -c "for ENV_VAR in $(cat); do echo \$ENV_VAR |sed 's@^\([^=]*\)=\(.*\)\$@echo \\\"\2\\\" >/tmp/env/\1@g' >>/tmp/set_env.sh; done && mkdir -p /tmp/env && /bin/bash /tmp/set_env.sh")
+8 -8
View File
@@ -9,15 +9,15 @@ function has_tty() {
fi fi
} }
function info1() { function dokku_log_info1() {
echo "-----> $@" echo "-----> $@"
} }
function info2() { function dokku_log_info2() {
echo "=====> $@" echo "=====> $@"
} }
function info1_quiet() { function dokku_log_info1_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
echo "-----> $@" echo "-----> $@"
else else
@@ -25,7 +25,7 @@ function info1_quiet() {
fi fi
} }
function info2_quiet() { function dokku_log_info2_quiet() {
if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then if [[ -z "$DOKKU_QUIET_OUTPUT" ]];then
echo "=====> $@" echo "=====> $@"
else else
@@ -33,22 +33,22 @@ function info2_quiet() {
fi fi
} }
function verbose() { function dokku_log_verbose() {
echo " $@" echo " $@"
} }
function warn() { function dokku_log_warn() {
echo " ! $@" echo " ! $@"
} }
function fail() { function dokku_log_fail() {
echo "$@" 1>&2 echo "$@" 1>&2
exit 1 exit 1
} }
function verify_app_name() { function verify_app_name() {
local APP="$1" local APP="$1"
[[ ! -d "$DOKKU_ROOT/$APP" ]] && fail "App $APP does not exist" [[ ! -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "App $APP does not exist"
return 0 return 0
} }
+3 -3
View File
@@ -65,7 +65,7 @@ case "$1" in
fi fi
done done
info2 "$APP config vars" dokku_log_info2_quiet "$APP config vars"
config_styled_hash "$VARS" config_styled_hash "$VARS"
;; ;;
@@ -131,7 +131,7 @@ ${var}"
ENV_ADD=$(echo "$ENV_ADD" | tail -n +2) #remove first empty line ENV_ADD=$(echo "$ENV_ADD" | tail -n +2) #remove first empty line
if [ $RESTART_APP ]; then if [ $RESTART_APP ]; then
info1 "Setting config vars and restarting $APP" dokku_log_info1 "Setting config vars and restarting $APP"
config_styled_hash "$ENV_ADD" " " config_styled_hash "$ENV_ADD" " "
config_write "$ENV_TEMP" config_write "$ENV_TEMP"
@@ -154,7 +154,7 @@ ${var}"
VARS="${*:3}" VARS="${*:3}"
for var in $VARS; do for var in $VARS; do
info1 "Unsetting $var and restarting $APP" dokku_log_info1 "Unsetting $var and restarting $APP"
ENV_TEMP=$(echo -e "${ENV_TEMP}" | sed "/^export $var=/ d") ENV_TEMP=$(echo -e "${ENV_TEMP}" | sed "/^export $var=/ d")
config_write "$ENV_TEMP" config_write "$ENV_TEMP"
+5 -5
View File
@@ -24,7 +24,7 @@ case "$1" in
APP="$2" APP="$2"
dokku domains:setup $APP dokku domains:setup $APP
info2 "$APP Domain Names" dokku_log_info2_quiet "$APP Domain Names"
cat "$DOKKU_ROOT/$APP/VHOST" cat "$DOKKU_ROOT/$APP/VHOST"
;; ;;
@@ -44,7 +44,7 @@ case "$1" in
[[ ! $(grep -q NO_VHOST "$DOKKU_ROOT/$APP/ENV") ]] && echo "export NO_VHOST='1'" >> "$DOKKU_ROOT/$APP/ENV" [[ ! $(grep -q NO_VHOST "$DOKKU_ROOT/$APP/ENV") ]] && echo "export NO_VHOST='1'" >> "$DOKKU_ROOT/$APP/ENV"
else else
if [[ -f "$DOKKU_ROOT/VHOST" ]]; then if [[ -f "$DOKKU_ROOT/VHOST" ]]; then
info1 "Creating new $VHOST_PATH..." dokku_log_info1 "Creating new $VHOST_PATH..."
SUBDOMAIN=${APP/%\.${VHOST}/} SUBDOMAIN=${APP/%\.${VHOST}/}
hostname=$(: | pluginhook nginx-hostname $APP $SUBDOMAIN $VHOST) hostname=$(: | pluginhook nginx-hostname $APP $SUBDOMAIN $VHOST)
if [[ ! -n $hostname ]]; then if [[ ! -n $hostname ]]; then
@@ -82,7 +82,7 @@ case "$1" in
# we need to restart the app to make sure we're binding to the appropriate network interface # we need to restart the app to make sure we're binding to the appropriate network interface
dokku ps:restart $APP dokku ps:restart $APP
pluginhook post-domains-update $APP pluginhook post-domains-update $APP
info1 "Added $3 to $APP" dokku_log_info1 "Added $3 to $APP"
;; ;;
@@ -94,7 +94,7 @@ case "$1" in
rm -f "$DOKKU_ROOT/$APP/VHOST" rm -f "$DOKKU_ROOT/$APP/VHOST"
dokku domains:setup $APP dokku domains:setup $APP
pluginhook post-domains-update $APP pluginhook post-domains-update $APP
info1 "Cleared domains in $APP" dokku_log_info1 "Cleared domains in $APP"
;; ;;
@@ -112,7 +112,7 @@ case "$1" in
dokku domains:setup $APP dokku domains:setup $APP
sed -i "/^$3$/d" "$DOKKU_ROOT/$APP/VHOST" sed -i "/^$3$/d" "$DOKKU_ROOT/$APP/VHOST"
pluginhook post-domains-update $APP pluginhook post-domains-update $APP
info1 "Removed $3 from $APP" dokku_log_info1 "Removed $3 from $APP"
;; ;;
+7 -7
View File
@@ -63,7 +63,7 @@ EOF
NONSSL_VHOSTS=$(egrep -v "^${SSL_HOSTNAME}$|^${SSL_HOSTNAME_ALT}$" $VHOST_PATH || exit 0) NONSSL_VHOSTS=$(egrep -v "^${SSL_HOSTNAME}$|^${SSL_HOSTNAME_ALT}$" $VHOST_PATH || exit 0)
while read line; do while read line; do
info1 "Configuring SSL for $line..." dokku_log_info1 "Configuring SSL for $line..."
SSL_SERVER_NAME=$line SSL_SERVER_NAME=$line
eval "cat <<< \"$(< $NGINX_CONF)\" >> $DOKKU_ROOT/$APP/nginx.conf" eval "cat <<< \"$(< $NGINX_CONF)\" >> $DOKKU_ROOT/$APP/nginx.conf"
done <<< "$SSL_VHOSTS" done <<< "$SSL_VHOSTS"
@@ -71,7 +71,7 @@ EOF
APP_NGINX_TEMPLATE="$DOKKU_ROOT/$APP/nginx.conf.template" APP_NGINX_TEMPLATE="$DOKKU_ROOT/$APP/nginx.conf.template"
if [[ -f $APP_NGINX_TEMPLATE ]]; then if [[ -f $APP_NGINX_TEMPLATE ]]; then
info1 "Overriding default nginx.conf with detected nginx.conf.template" dokku_log_info1 "Overriding default nginx.conf with detected nginx.conf.template"
NGINX_CONF=$APP_NGINX_TEMPLATE NGINX_CONF=$APP_NGINX_TEMPLATE
fi fi
@@ -80,11 +80,11 @@ EOF
NOSSL_SERVER_NAME=$(echo $NONSSL_VHOSTS $SSL_VHOSTS| tr '\n' ' ') NOSSL_SERVER_NAME=$(echo $NONSSL_VHOSTS $SSL_VHOSTS| tr '\n' ' ')
if [[ -n "$DOKKU_APP_LISTEN_PORT" ]] && [[ -n "$DOKKU_APP_LISTEN_IP" ]]; then if [[ -n "$DOKKU_APP_LISTEN_PORT" ]] && [[ -n "$DOKKU_APP_LISTEN_IP" ]]; then
info1 "Creating $SCHEME nginx.conf" dokku_log_info1 "Creating $SCHEME nginx.conf"
echo "upstream $APP { server $DOKKU_APP_LISTEN_IP:$DOKKU_APP_LISTEN_PORT; }" > $DOKKU_ROOT/$APP/nginx.conf echo "upstream $APP { server $DOKKU_APP_LISTEN_IP:$DOKKU_APP_LISTEN_PORT; }" > $DOKKU_ROOT/$APP/nginx.conf
eval "cat <<< \"$(< $NGINX_CONF)\" >> $DOKKU_ROOT/$APP/nginx.conf" eval "cat <<< \"$(< $NGINX_CONF)\" >> $DOKKU_ROOT/$APP/nginx.conf"
info1 "Running nginx-pre-reload" dokku_log_info1 "Running nginx-pre-reload"
pluginhook nginx-pre-reload $APP $DOKKU_APP_LISTEN_PORT $DOKKU_APP_LISTEN_IP pluginhook nginx-pre-reload $APP $DOKKU_APP_LISTEN_PORT $DOKKU_APP_LISTEN_IP
echo " Reloading nginx" echo " Reloading nginx"
@@ -92,14 +92,14 @@ EOF
fi fi
else else
if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
info1 "VHOST support disabled, deleting $APP/VHOST" dokku_log_info1 "VHOST support disabled, deleting $APP/VHOST"
rm "$DOKKU_ROOT/$APP/VHOST" rm "$DOKKU_ROOT/$APP/VHOST"
fi fi
if [[ -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then if [[ -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then
info1 "VHOST support disabled, deleting nginx.conf" dokku_log_info1 "VHOST support disabled, deleting nginx.conf"
rm "$DOKKU_ROOT/$APP/nginx.conf" rm "$DOKKU_ROOT/$APP/nginx.conf"
info1 "VHOST support disabled, reloading nginx after nginx.conf deletion" dokku_log_info1 "VHOST support disabled, reloading nginx after nginx.conf deletion"
restart_nginx restart_nginx
fi fi
fi fi
+1 -1
View File
@@ -7,7 +7,7 @@ APP="$1"; PORT="$2"; IP="$3"
set +e; NO_VHOST=$(dokku config:get $APP NO_VHOST); set -e set +e; NO_VHOST=$(dokku config:get $APP NO_VHOST); set -e
if [[ -n "$NO_VHOST" ]]; then if [[ -n "$NO_VHOST" ]]; then
info1 "NO_VHOST config detected" dokku_log_info1 "NO_VHOST config detected"
elif [[ ! -f "$DOKKU_ROOT/$APP/VHOST" ]]; then elif [[ ! -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
dokku domains:setup $APP dokku domains:setup $APP
fi fi
+4 -4
View File
@@ -7,12 +7,12 @@ release_and_deploy() {
local APP="$1"; local APP="$1";
if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then
info1 "Releasing $APP ..." dokku_log_info1 "Releasing $APP ..."
dokku release $APP dokku release $APP
info1 "Release complete!" dokku_log_info1 "Release complete!"
info1 "Deploying $APP ..." dokku_log_info1 "Deploying $APP ..."
dokku deploy $APP dokku deploy $APP
info2 "Application deployed:" dokku_log_info2 "Application deployed:"
dokku urls $APP | sed "s/^/ /" dokku urls $APP | sed "s/^/ /"
echo echo
fi fi