refactor: rename pre-restore trigger to scheduler-pre-restore

This better reflects what the trigger does, and allows us to use the pre-restore trigger at the beginning of the ps:restore command.
This commit is contained in:
Jose Diaz-Gonzalez committed 2022-11-29 01:38:36 -05:00
1 parent 77fbd676bc
commit 6fed37b408
6 files changed
+32 -7

No files matched your search

@@ -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 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 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 `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 ## Removals
+20 -1
View File
@@ -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 - Description: Allows you to run commands before all containers are restored
- Invoked by: `dokku ps:restore` - Invoked by: `dokku ps:restore`
- Arguments: `$DOKKU_SCHEDULER $APP` - Arguments:
- Example: - Example:
```shell ```shell
@@ -2187,6 +2187,25 @@ DOKKU_SCHEDULER="$1"; APP="$2";
# TODO # 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` ### `scheduler-post-delete`
> Warning: The scheduler plugin trigger apis are under development and may change > Warning: The scheduler plugin trigger apis are under development and may change
+1
View File
@@ -0,0 +1 @@
hook
+2 -2
View File
@@ -115,8 +115,8 @@ func RestartProcess(appName string, processName string) error {
// Restore ensures an app that should be running is running on boot // Restore ensures an app that should be running is running on boot
func Restore(appName string) error { func Restore(appName string) error {
scheduler := common.GetAppScheduler(appName) scheduler := common.GetAppScheduler(appName)
if err := common.PlugnTrigger("pre-restore", []string{scheduler, appName}...); err != nil { if err := common.PlugnTrigger("scheduler-pre-restore", []string{scheduler, appName}...); err != nil {
return fmt.Errorf("Error running pre-restore: %s", err) return fmt.Errorf("Error running scheduler-pre-restore: %s", err)
} }
common.LogInfo1("Clearing potentially invalid proxy configuration") common.LogInfo1("Clearing potentially invalid proxy configuration")
+4
View File
@@ -74,6 +74,10 @@ func CommandRestart(appName string, processName string, allApps bool, parallelCo
// CommandRestore starts previously running apps e.g. after reboot // CommandRestore starts previously running apps e.g. after reboot
func CommandRestore(appName string, allApps bool, parallelCount int) error { 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 allApps {
if err := restorePrep(); err != nil { if err := restorePrep(); err != nil {
return err return err
@@ -3,9 +3,9 @@ set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
trigger-scheduler-docker-local-pre-restore() { trigger-scheduler-docker-local-scheduler-pre-restore() {
declare desc="scheduler-docker-local pre-restore plugin trigger" declare desc="scheduler-docker-local scheduler-pre-restore plugin trigger"
declare trigger="pre-restore" declare trigger="scheduler-pre-restore"
declare DOKKU_SCHEDULER="$1" declare DOKKU_SCHEDULER="$1"
if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then 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 "$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 "$@"