Restart app only if config changed
This commit is contained in:
committed by
Jose Diaz-Gonzalez
parent
5f5e05bba6
commit
0ec9ecad08
@@ -9,6 +9,7 @@ if [[ $1 == config ]] || [[ $1 == config:* ]]; then
|
|||||||
else
|
else
|
||||||
APP="$2"
|
APP="$2"
|
||||||
ENV_FILE="$DOKKU_ROOT/$APP/ENV"
|
ENV_FILE="$DOKKU_ROOT/$APP/ENV"
|
||||||
|
ENV_FILE_TEMP="$DOKKU_ROOT/$APP/ENV.tmp"
|
||||||
|
|
||||||
# Check if app exists with the same name
|
# Check if app exists with the same name
|
||||||
if [ ! -d "$DOKKU_ROOT/$APP" ]; then
|
if [ ! -d "$DOKKU_ROOT/$APP" ]; then
|
||||||
@@ -59,6 +60,16 @@ config_restart_app() {
|
|||||||
echo "-----> Deploy complete!"
|
echo "-----> Deploy complete!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config_write() {
|
||||||
|
ENV_TEMP="$1"
|
||||||
|
echo -e "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE_TEMP
|
||||||
|
if ! cmp -s $ENV_FILE $ENV_FILE_TEMP; then
|
||||||
|
cp -f $ENV_FILE_TEMP $ENV_FILE
|
||||||
|
config_restart_app $APP
|
||||||
|
fi
|
||||||
|
rm -f $ENV_FILE_TEMP
|
||||||
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
||||||
config)
|
config)
|
||||||
@@ -136,8 +147,7 @@ case "$1" in
|
|||||||
echo "-----> Setting config vars and restarting $APP"
|
echo "-----> Setting config vars and restarting $APP"
|
||||||
config_styled_hash "$ENV_ADD"
|
config_styled_hash "$ENV_ADD"
|
||||||
|
|
||||||
echo -e "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE
|
config_write "$ENV_TEMP"
|
||||||
config_restart_app $APP
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -156,8 +166,7 @@ case "$1" in
|
|||||||
echo "-----> Unsetting $var and restarting $APP"
|
echo "-----> 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")
|
||||||
|
|
||||||
echo -e "$ENV_TEMP" | sed '/^$/d' | sort > $ENV_FILE
|
config_write "$ENV_TEMP"
|
||||||
config_restart_app $APP
|
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user