Merge pull request #1613 from kdomanski/restore

add ps:restore to start applications which weren't manually stopped
This commit is contained in:
Jose Diaz-Gonzalez
2015-10-28 14:15:57 -04:00
3 changed files with 32 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash
[[ " ps ps:start ps:stop ps:rebuild ps:rebuildall ps:restart ps:restartall ps:scale help ps:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT
[[ " ps ps:start ps:stop ps:rebuild ps:rebuildall ps:restart ps:restartall ps:restore ps:scale help ps:help " == *" $1 "* ]] || exit $DOKKU_NOT_IMPLEMENTED_EXIT
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
@@ -84,6 +84,20 @@ case "$1" in
shopt -u nullglob
;;
ps:restore)
shopt -s nullglob
for app in $DOKKU_ROOT/*; do
[[ ! -d $app ]] && continue
APP=$(basename $app)
RESTORE=$(dokku config:get $APP RESTORE || true)
if [[ $RESTORE != 0 ]]; then
echo "Restoring app $APP ..."
dokku ps:start $APP
fi
done
shopt -u nullglob
;;
ps:scale)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
APP="$2"; IMAGE_TAG=$(get_running_image_tag $APP)
@@ -119,6 +133,7 @@ case "$1" in
ps:rebuildall, Rebuild all apps
ps:restart <app>, Restart app container(s)
ps:restartall, Restart all deployed app containers
ps:restore, Start previously running apps e.g. after reboot
EOF
;;

8
plugins/ps/post-deploy Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
APP="$1"
dokku config:set --no-restart $APP RESTORE=1

8
plugins/ps/post-stop Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
APP="$1"
dokku config:set --no-restart $APP RESTORE=0