Move post-deploy trigger to core-post-deploy. Refs #2367

This avoids issues where community plugins may break core commands because of issues in the command output.
This commit is contained in:
Jose Diaz-Gonzalez
2016-09-05 00:04:06 -04:00
parent 0841888b67
commit 2fc3a09b41
7 changed files with 36 additions and 14 deletions

View File

@@ -134,6 +134,24 @@ help_content
esac esac
``` ```
### `core-post-deploy`
> To avoid issues with community plugins, this plugin trigger should be used *only* for core plugins. Please avoid using this trigger in your own plugins.
- Description: Allows running of commands after an application's processes have been scaled up, but before old containers are torn down. Dokku core currently uses this to switch traffic on nginx.
- Invoked by: `dokku deploy`
- Arguments: `$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG`
- Example:
```shell
#!/usr/bin/env bash
# Notify an external service that a successful deploy has occurred.
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
curl "http://httpstat.us/200"
```
### `dependencies` ### `dependencies`
- Description: Used to install system-level dependencies. Invoked by `plugin:install-dependencies`. - Description: Used to install system-level dependencies. Invoked by `plugin:install-dependencies`.
@@ -430,7 +448,9 @@ dokku postgres:destroy $APP
### `post-deploy` ### `post-deploy`
- Description: Allows running of commands after an application's processes have been scaled up, but before old containers are torn down. Dokku core currently uses this to switch traffic on nginx. > Please see [core-post-deploy](#core-post-deploy) if contributing a core plugin with the `post-deploy` hook.
- Description: Allows running of commands after an application's processes have been scaled up, but before old containers are torn down. Dokku calls this _after_ `core-post-deploy`.
- Invoked by: `dokku deploy` - Invoked by: `dokku deploy`
- Arguments: `$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG` - Arguments: `$APP $INTERNAL_PORT $INTERNAL_IP_ADDRESS $IMAGE_TAG`
- Example: - Example:

View File

@@ -5,7 +5,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/00_dokku-standard/exec-app-json-scripts"
exec_app_json_scripts() { exec_app_json_scripts() {
declare desc="core app.json scripts execution" declare desc="core app.json scripts execution"
local trigger="pre-deploy app_json_scripts" local trigger="core-post-deploy app_json_scripts"
local APP="$1"; local IMAGE_TAG="$4"; local PHASE_SCRIPT_KEY="postdeploy" local APP="$1"; local IMAGE_TAG="$4"; local PHASE_SCRIPT_KEY="postdeploy"
dokku_log_info1 "Attempting to run scripts.dokku.$PHASE_SCRIPT_KEY from app.json (if defined)" dokku_log_info1 "Attempting to run scripts.dokku.$PHASE_SCRIPT_KEY from app.json (if defined)"
@@ -14,7 +14,7 @@ exec_app_json_scripts() {
cleanup_container_state() { cleanup_container_state() {
declare desc="core post-deploy state cleanup" declare desc="core post-deploy state cleanup"
local trigger="post-deploy cleanup_container_state" local trigger="core-post-deploy cleanup_container_state"
local APP="$1"; local PROCTYPES="$(egrep -v "^#" "$DOKKU_ROOT/$APP/DOKKU_SCALE" | awk -F '=' '{ print $1 }' | xargs)" local APP="$1"; local PROCTYPES="$(egrep -v "^#" "$DOKKU_ROOT/$APP/DOKKU_SCALE" | awk -F '=' '{ print $1 }' | xargs)"
local CONTAINER_FILES="$(find "$DOKKU_ROOT/$APP" -maxdepth 1 -name "CONTAINER.*" -printf "%f\n" 2>/dev/null | sort -t . -k 3 -n | xargs)" local CONTAINER_FILES="$(find "$DOKKU_ROOT/$APP" -maxdepth 1 -name "CONTAINER.*" -printf "%f\n" 2>/dev/null | sort -t . -k 3 -n | xargs)"

View File

@@ -0,0 +1 @@
hook

View File

@@ -646,6 +646,7 @@ dokku_deploy_cmd() {
done < "$DOKKU_SCALE_FILE" done < "$DOKKU_SCALE_FILE"
dokku_log_info1 "Running post-deploy" dokku_log_info1 "Running post-deploy"
plugn trigger core-post-deploy "$APP" "$port" "$ipaddr" "$IMAGE_TAG"
plugn trigger post-deploy "$APP" "$port" "$ipaddr" "$IMAGE_TAG" plugn trigger post-deploy "$APP" "$port" "$ipaddr" "$IMAGE_TAG"
# kill the old container # kill the old container

View File

@@ -2,9 +2,9 @@
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
named_containers_post_deploy() { named_containers_core_post_deploy() {
declare desc="names deployed app container is consistent manner" declare desc="names deployed app container is consistent manner"
local trigger="named_containers_post_deploy" local trigger="named_containers_core_post_deploy"
local APP="$1"; local APP_ROOT="$DOKKU_ROOT/$APP" local APP="$1"; local APP_ROOT="$DOKKU_ROOT/$APP"
local container local container
@@ -38,4 +38,4 @@ named_containers_post_deploy() {
shopt -u nullglob shopt -u nullglob
} }
named_containers_post_deploy "$@" named_containers_core_post_deploy "$@"

View File

@@ -5,9 +5,9 @@ source "$PLUGIN_AVAILABLE_PATH/domains/functions"
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions" source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
source "$PLUGIN_AVAILABLE_PATH/proxy/functions" source "$PLUGIN_AVAILABLE_PATH/proxy/functions"
nginx_post_deploy() { nginx_core_post_deploy() {
declare desc="nginx-vhosts post-deploy plugin trigger" declare desc="nginx-vhosts core-post-deploy plugin trigger"
local trigger="nginx_post_deploy" local trigger="nginx_core_post_deploy"
local APP="$1" local APP="$1"
if [[ -f "$DOKKU_ROOT/$APP/IP.web.1" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT.web.1" ]]; then if [[ -f "$DOKKU_ROOT/$APP/IP.web.1" ]] && [[ -f "$DOKKU_ROOT/$APP/PORT.web.1" ]]; then
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
@@ -21,5 +21,5 @@ nginx_post_deploy() {
} }
if [[ "$(get_app_proxy_type "$1")" == "nginx" ]]; then if [[ "$(get_app_proxy_type "$1")" == "nginx" ]]; then
nginx_post_deploy "$@" nginx_core_post_deploy "$@"
fi fi

View File

@@ -4,13 +4,13 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions" source "$PLUGIN_AVAILABLE_PATH/config/functions"
source "$PLUGIN_AVAILABLE_PATH/ps/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions"
ps_post_deploy() { ps_core_post_deploy() {
declare desc="ps post-deploy plugin trigger" declare desc="ps core-post-deploy plugin trigger"
local trigger="ps_post_deploy" local trigger="ps_core_post_deploy"
local APP="$1" local APP="$1"
remove_procfile "$APP" remove_procfile "$APP"
config_set --no-restart "$APP" DOKKU_APP_RESTORE=1 config_set --no-restart "$APP" DOKKU_APP_RESTORE=1
} }
ps_post_deploy "$@" ps_core_post_deploy "$@"