diff --git a/plugins/ps/commands b/plugins/ps/commands index d7618d4cc94..e6b47828990 100755 --- a/plugins/ps/commands +++ b/plugins/ps/commands @@ -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 , Restart app container(s) ps:restartall, Restart all deployed app containers + ps:restore, Start previously running apps e.g. after reboot EOF ;; diff --git a/plugins/ps/post-deploy b/plugins/ps/post-deploy new file mode 100755 index 00000000000..956712ee74a --- /dev/null +++ b/plugins/ps/post-deploy @@ -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 diff --git a/plugins/ps/post-stop b/plugins/ps/post-stop new file mode 100755 index 00000000000..8c4d9f2b8db --- /dev/null +++ b/plugins/ps/post-stop @@ -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