Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c17773fb2 | ||
|
|
980e7d1650 | ||
|
|
64394619b5 | ||
|
|
a39ade3161 | ||
|
|
20dd893a77 | ||
|
|
e089d0d03d | ||
|
|
ab9da6349e | ||
|
|
c2ed798db0 | ||
|
|
63fc31807c | ||
|
|
284ffa3177 |
@@ -46,6 +46,7 @@ mysql:start <name> Start a previously stopped mysql service
|
|||||||
mysql:stop <name> Stop a running mysql service
|
mysql:stop <name> Stop a running mysql service
|
||||||
mysql:unexpose <name> Unexpose a previously exposed mysql service
|
mysql:unexpose <name> Unexpose a previously exposed mysql service
|
||||||
mysql:unlink <name> <app> Unlink the mysql service from the app
|
mysql:unlink <name> <app> Unlink the mysql service from the app
|
||||||
|
mysql:upgrade <name> Upgrade service <service> to the specified version
|
||||||
```
|
```
|
||||||
|
|
||||||
## usage
|
## usage
|
||||||
|
|||||||
@@ -273,6 +273,18 @@ service_backup_unset_encryption() {
|
|||||||
rm -rf "$SERVICE_BACKUP_ENCRYPTION_ROOT"
|
rm -rf "$SERVICE_BACKUP_ENCRYPTION_ROOT"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service_container_rm() {
|
||||||
|
declare desc="Stops a service and removes the running container"
|
||||||
|
declare SERVICE="$1"
|
||||||
|
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||||
|
|
||||||
|
service_stop "$SERVICE"
|
||||||
|
dokku_log_verbose_quiet "Removing container"
|
||||||
|
if ! docker rm "$SERVICE_NAME" > /dev/null 2>&1; then
|
||||||
|
dokku_log_fail "Unable to remove container for service $SERVICE"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
service_enter() {
|
service_enter() {
|
||||||
declare desc="enters running app container of specified proc type"
|
declare desc="enters running app container of specified proc type"
|
||||||
declare SERVICE="$1" && shift 1
|
declare SERVICE="$1" && shift 1
|
||||||
@@ -300,6 +312,17 @@ service_exposed_ports() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service_image_exists() {
|
||||||
|
declare desc="Checks if the current image exists"
|
||||||
|
local IMAGE="$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION"
|
||||||
|
|
||||||
|
if [[ "$(docker images -q "$IMAGE" 2> /dev/null)" == "" ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
service_info() {
|
service_info() {
|
||||||
declare desc="Retrieves information about a given service"
|
declare desc="Retrieves information about a given service"
|
||||||
declare SERVICE="$1" INFO_FLAG="$2"
|
declare SERVICE="$1" INFO_FLAG="$2"
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ service_create() {
|
|||||||
|
|
||||||
service_parse_args "${@:2}"
|
service_parse_args "${@:2}"
|
||||||
|
|
||||||
if ! docker images | grep -e "^$PLUGIN_IMAGE " | grep -q " $PLUGIN_IMAGE_VERSION " ; then
|
if ! service_image_exists "$SERVICE"; then
|
||||||
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
|
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
|
||||||
dokku_log_warn "${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
|
dokku_log_warn "${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
|
||||||
dokku_log_warn " docker pull ${IMAGE}" 1>&2
|
dokku_log_warn " docker pull ${IMAGE}" 1>&2
|
||||||
@@ -127,7 +127,6 @@ service_start() {
|
|||||||
|
|
||||||
dokku_log_info2_quiet "Starting container"
|
dokku_log_info2_quiet "Starting container"
|
||||||
local PREVIOUS_ID=$(docker ps -f status=exited | grep -e "$SERVICE_NAME$" | awk '{print $1}') || true
|
local PREVIOUS_ID=$(docker ps -f status=exited | grep -e "$SERVICE_NAME$" | awk '{print $1}') || true
|
||||||
local IMAGE_EXISTS=$(docker images | grep -e "^$PLUGIN_IMAGE " | grep -q " $PLUGIN_IMAGE_VERSION " && true)
|
|
||||||
local ROOTPASSWORD="$(cat "$SERVICE_ROOT/ROOTPASSWORD")"
|
local ROOTPASSWORD="$(cat "$SERVICE_ROOT/ROOTPASSWORD")"
|
||||||
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")"
|
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")"
|
||||||
|
|
||||||
@@ -135,7 +134,7 @@ service_start() {
|
|||||||
docker start "$PREVIOUS_ID" > /dev/null
|
docker start "$PREVIOUS_ID" > /dev/null
|
||||||
service_port_unpause "$SERVICE"
|
service_port_unpause "$SERVICE"
|
||||||
dokku_log_info2 "Container started"
|
dokku_log_info2 "Container started"
|
||||||
elif $IMAGE_EXISTS && [[ -n "$ROOTPASSWORD" ]] && [[ -n "$PASSWORD" ]]; then
|
elif service_image_exists "$SERVICE" && [[ -n "$ROOTPASSWORD" ]] && [[ -n "$PASSWORD" ]]; then
|
||||||
service_create_container "$SERVICE"
|
service_create_container "$SERVICE"
|
||||||
else
|
else
|
||||||
dokku_log_verbose_quiet "Neither container nor valid configuration exists for $SERVICE"
|
dokku_log_verbose_quiet "Neither container nor valid configuration exists for $SERVICE"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[plugin]
|
[plugin]
|
||||||
description = "dokku mysql service plugin"
|
description = "dokku mysql service plugin"
|
||||||
version = "1.3.0"
|
version = "1.4.1"
|
||||||
[plugin.config]
|
[plugin.config]
|
||||||
|
|||||||
38
subcommands/upgrade
Executable file
38
subcommands/upgrade
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_BASE_PATH/common/functions"
|
||||||
|
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||||
|
|
||||||
|
service-upgrade-cmd() {
|
||||||
|
#E you can upgrade an existing service to a new image or image-version
|
||||||
|
#E dokku $PLUGIN_COMMAND_PREFIX:upgrade lolipop
|
||||||
|
#A service, service to run command against
|
||||||
|
#F -c|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with
|
||||||
|
#F -i|--image IMAGE, the image name to start the service with
|
||||||
|
#F -i|--image-version IMAGE_VERSION, the image version to start the service with
|
||||||
|
declare desc="upgrade service <service> to the specified versions"
|
||||||
|
local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||||
|
declare SERVICE="$1" UPGRADE_FLAG_LIST="${@:2}"
|
||||||
|
|
||||||
|
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
|
||||||
|
verify_service_name "$SERVICE"
|
||||||
|
|
||||||
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
|
local ID="$(cat "$SERVICE_ROOT/ID")"
|
||||||
|
is_container_status "$ID" "Running" || dokku_log_fail "Service ${SERVICE} container is not running"
|
||||||
|
|
||||||
|
service_parse_args "${@:2}"
|
||||||
|
|
||||||
|
if ! service_image_exists "$SERVICE"; then
|
||||||
|
dokku_log_fail "Unable to proceed with upgrade, image ${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION} does not exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
dokku_log_info2 "Upgrading $SERVICE to $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION"
|
||||||
|
dokku_log_info2 "Stopping $SERVICE"
|
||||||
|
service_container_rm "$SERVICE"
|
||||||
|
service_start "$SERVICE" "${@:2}"
|
||||||
|
dokku_log_info2 "Done"
|
||||||
|
}
|
||||||
|
|
||||||
|
service-upgrade-cmd "$@"
|
||||||
Reference in New Issue
Block a user