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
2022-11-22 23:18:45 -05:00
parent 77fbd676bc
commit 6fed37b408
6 changed files with 32 additions and 7 deletions

View File

@@ -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

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
- 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

View File

@@ -0,0 +1 @@
hook

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
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")

View File

@@ -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

View File

@@ -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 "$@"