diff --git a/docs/appendices/0.29.0-migration-guide.md b/docs/appendices/0.29.0-migration-guide.md index b02e83673..e262032ac 100644 --- a/docs/appendices/0.29.0-migration-guide.md +++ b/docs/appendices/0.29.0-migration-guide.md @@ -5,6 +5,7 @@ - The output of `run:detached` now uses the container name - eg. `node-js-app.run.1` - vs the container id. - The ID of `cron` tasks is now base36-encoded instead of base64-encoded. - The `nginx.conf.sigil` is now extracted when source code is extracted for a build and not from the built image. Users can specify alternative paths via the `nginx-conf-sigil-path` property of the `nginx` plugin. See the [nginx documentation](/docs/networking/proxies/nginx.md#customizing-the-nginx-configuration) for more information on how to configure the `nginx.conf.sigil` path for your application. +- The existing `pre-restore` hook has been renamed to `scheduler-pre-restore`. There is a new `pre-restore` hook that is triggered within the `ps:restore` command prior to restoring any apps. ## Removals diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index 72293c3a3..eca55a663 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -1753,7 +1753,7 @@ APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG) - Description: Allows you to run commands before all containers are restored - Invoked by: `dokku ps:restore` -- Arguments: `$DOKKU_SCHEDULER $APP` +- Arguments: - Example: ```shell @@ -2187,6 +2187,25 @@ DOKKU_SCHEDULER="$1"; APP="$2"; # TODO ``` +### `scheduler-pre-restore` + +> Warning: The scheduler plugin trigger apis are under development and may change +> between minor releases until the 1.0 release. + +- Description: Allows you to run commands before an app is restored +- Invoked by: `dokku ps:restore` +- Arguments: `$DOKU_SCHEDULER $APP` +- Example: + +```shell +#!/usr/bin/env bash + +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +DOKKU_SCHEDULER="$1"; APP="$2"; + +# TODO +``` + ### `scheduler-post-delete` > Warning: The scheduler plugin trigger apis are under development and may change diff --git a/plugins/20_events/scheduler-pre-restore b/plugins/20_events/scheduler-pre-restore new file mode 120000 index 000000000..5178a749f --- /dev/null +++ b/plugins/20_events/scheduler-pre-restore @@ -0,0 +1 @@ +hook \ No newline at end of file diff --git a/plugins/ps/ps.go b/plugins/ps/ps.go index 9d86e297b..0428edaa0 100644 --- a/plugins/ps/ps.go +++ b/plugins/ps/ps.go @@ -115,8 +115,8 @@ func RestartProcess(appName string, processName string) error { // Restore ensures an app that should be running is running on boot func Restore(appName string) error { scheduler := common.GetAppScheduler(appName) - if err := common.PlugnTrigger("pre-restore", []string{scheduler, appName}...); err != nil { - return fmt.Errorf("Error running pre-restore: %s", err) + if err := common.PlugnTrigger("scheduler-pre-restore", []string{scheduler, appName}...); err != nil { + return fmt.Errorf("Error running scheduler-pre-restore: %s", err) } common.LogInfo1("Clearing potentially invalid proxy configuration") diff --git a/plugins/ps/subcommands.go b/plugins/ps/subcommands.go index 442ffe062..02aeb2058 100644 --- a/plugins/ps/subcommands.go +++ b/plugins/ps/subcommands.go @@ -74,6 +74,10 @@ func CommandRestart(appName string, processName string, allApps bool, parallelCo // CommandRestore starts previously running apps e.g. after reboot func CommandRestore(appName string, allApps bool, parallelCount int) error { + if err := common.PlugnTrigger("pre-restore", []string{}...); err != nil { + return fmt.Errorf("Error running pre-restore: %s", err) + } + if allApps { if err := restorePrep(); err != nil { return err diff --git a/plugins/scheduler-docker-local/pre-restore b/plugins/scheduler-docker-local/scheduler-pre-restore similarity index 67% rename from plugins/scheduler-docker-local/pre-restore rename to plugins/scheduler-docker-local/scheduler-pre-restore index db4e8f34f..6a88d8ea4 100755 --- a/plugins/scheduler-docker-local/pre-restore +++ b/plugins/scheduler-docker-local/scheduler-pre-restore @@ -3,9 +3,9 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -trigger-scheduler-docker-local-pre-restore() { - declare desc="scheduler-docker-local pre-restore plugin trigger" - declare trigger="pre-restore" +trigger-scheduler-docker-local-scheduler-pre-restore() { + declare desc="scheduler-docker-local scheduler-pre-restore plugin trigger" + declare trigger="scheduler-pre-restore" declare DOKKU_SCHEDULER="$1" if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then @@ -17,4 +17,4 @@ trigger-scheduler-docker-local-pre-restore() { "$DOCKER_BIN" container rm $("$DOCKER_BIN" container list --all --format "{{.Names}}" --filter "label=$DOKKU_CONTAINER_LABEL" --quiet | grep -E '(.+\..+\.[0-9]+\.[0-9]+$)') &>/dev/null || true } -trigger-scheduler-docker-local-pre-restore "$@" +trigger-scheduler-docker-local-scheduler-pre-restore "$@"