Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0c8375c3a | ||
|
|
3781dec5f7 | ||
|
|
84101e17e9 | ||
|
|
a68d2e71d0 | ||
|
|
d99ae93279 | ||
|
|
af01981e52 | ||
|
|
1c7d121a07 | ||
|
|
2f33b6deb3 | ||
|
|
78d74dfc3c | ||
|
|
5ad84c4efe | ||
|
|
46a940fd28 | ||
|
|
5c21b534d4 | ||
|
|
f1d60d6f4b | ||
|
|
32fdea93fd | ||
|
|
42f07d10a8 | ||
|
|
5e3cf5fab4 | ||
|
|
4174b7e617 |
@@ -1 +1 @@
|
|||||||
FROM postgres:13.4
|
FROM postgres:14.1
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -40,7 +40,7 @@ postgres:link <service> <app> [--link-flags...] # link the postgres service t
|
|||||||
postgres:linked <service> <app> # check if the postgres service is linked to an app
|
postgres:linked <service> <app> # check if the postgres service is linked to an app
|
||||||
postgres:links <service> # list all apps linked to the postgres service
|
postgres:links <service> # list all apps linked to the postgres service
|
||||||
postgres:list # list all postgres services
|
postgres:list # list all postgres services
|
||||||
postgres:logs <service> [-t|--tail] # print the most recent log(s) for this service
|
postgres:logs <service> [-t|--tail] <tail-num-optional> # print the most recent log(s) for this service
|
||||||
postgres:promote <service> <app> # promote service <service> as DATABASE_URL in <app>
|
postgres:promote <service> <app> # promote service <service> as DATABASE_URL in <app>
|
||||||
postgres:restart <service> # graceful shutdown and restart of the postgres service container
|
postgres:restart <service> # graceful shutdown and restart of the postgres service container
|
||||||
postgres:start <service> # start a previously stopped postgres service
|
postgres:start <service> # start a previously stopped postgres service
|
||||||
@@ -159,12 +159,12 @@ dokku postgres:list
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
# usage
|
# usage
|
||||||
dokku postgres:logs <service> [-t|--tail]
|
dokku postgres:logs <service> [-t|--tail] <tail-num-optional>
|
||||||
```
|
```
|
||||||
|
|
||||||
flags:
|
flags:
|
||||||
|
|
||||||
- `-t|--tail`: do not stop when end of the logs are reached and wait for additional output
|
- `-t|--tail [<tail-num>]`: do not stop when end of the logs are reached and wait for additional output
|
||||||
|
|
||||||
You can tail logs for a particular service:
|
You can tail logs for a particular service:
|
||||||
|
|
||||||
@@ -178,6 +178,12 @@ By default, logs will not be tailed, but you can do this with the --tail flag:
|
|||||||
dokku postgres:logs lollipop --tail
|
dokku postgres:logs lollipop --tail
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The default tail setting is to show all logs, but an initial count can also be specified:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
dokku postgres:logs lollipop --tail 5
|
||||||
|
```
|
||||||
|
|
||||||
### link the postgres service to the app
|
### link the postgres service to the app
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -561,7 +567,7 @@ dokku postgres:export lollipop > data.dump
|
|||||||
Note that the export will result in a file containing the binary postgres export data. It can be converted to plain text using `pg_restore` as follows
|
Note that the export will result in a file containing the binary postgres export data. It can be converted to plain text using `pg_restore` as follows
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pg_restore data.dump -f plain.sql.
|
pg_restore data.dump -f plain.sql
|
||||||
```
|
```
|
||||||
|
|
||||||
### Backups
|
### Backups
|
||||||
|
|||||||
@@ -4,6 +4,18 @@ set -eo pipefail
|
|||||||
[[ $DOKKU_TRACE ]] && set -x
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
|
|
||||||
|
add_to_links_file() {
|
||||||
|
declare desc="add an app to the service link file"
|
||||||
|
declare SERVICE="$1" APP="$2"
|
||||||
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
|
local LINKS_FILE="$SERVICE_ROOT/LINKS"
|
||||||
|
|
||||||
|
touch "$LINKS_FILE"
|
||||||
|
sed -i.bak "/^$APP\$/d" "$LINKS_FILE" && rm "$LINKS_FILE.bak"
|
||||||
|
echo "$APP" >>"$LINKS_FILE"
|
||||||
|
sort "$LINKS_FILE" -u -o "$LINKS_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
docker_ports_options() {
|
docker_ports_options() {
|
||||||
declare desc="export a list of exposed ports"
|
declare desc="export a list of exposed ports"
|
||||||
declare PORTS=("$@")
|
declare PORTS=("$@")
|
||||||
@@ -61,6 +73,15 @@ get_url_from_config() {
|
|||||||
echo "$EXISTING_CONFIG" | grep "$CONFIG_VAR" | sed "s/$CONFIG_VAR:\s*//" | xargs
|
echo "$EXISTING_CONFIG" | grep "$CONFIG_VAR" | sed "s/$CONFIG_VAR:\s*//" | xargs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
in_links_file() {
|
||||||
|
declare desc="check if a service LINKS file contains an app"
|
||||||
|
declare SERVICE="$1" APP="$2"
|
||||||
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
|
local LINKS_FILE="$SERVICE_ROOT/LINKS"
|
||||||
|
|
||||||
|
grep -qE "^$APP\$" "$LINKS_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
is_container_status() {
|
is_container_status() {
|
||||||
declare desc="return 0 or 1 depending upon whether a given container has a certain status"
|
declare desc="return 0 or 1 depending upon whether a given container has a certain status"
|
||||||
declare CID="$1" STATUS="$2"
|
declare CID="$1" STATUS="$2"
|
||||||
@@ -430,7 +451,7 @@ service_info() {
|
|||||||
|
|
||||||
local flag_map=(
|
local flag_map=(
|
||||||
"--config-dir: ${SERVICE_ROOT}/${PLUGIN_CONFIG_SUFFIX}"
|
"--config-dir: ${SERVICE_ROOT}/${PLUGIN_CONFIG_SUFFIX}"
|
||||||
"--config-options: $(cat "$SERVICE_ROOT/CONFIG_OPTIONS")"
|
"--config-options: $(cat "$SERVICE_ROOT/CONFIG_OPTIONS" 2>/dev/null || true)"
|
||||||
"--data-dir: ${SERVICE_ROOT}/data"
|
"--data-dir: ${SERVICE_ROOT}/data"
|
||||||
"--dsn: ${SERVICE_URL}"
|
"--dsn: ${SERVICE_URL}"
|
||||||
"--exposed-ports: $(service_exposed_ports "$SERVICE")"
|
"--exposed-ports: $(service_exposed_ports "$SERVICE")"
|
||||||
@@ -442,7 +463,7 @@ service_info() {
|
|||||||
"--version: $(service_version "$SERVICE")"
|
"--version: $(service_version "$SERVICE")"
|
||||||
)
|
)
|
||||||
if [[ -z "$INFO_FLAG" ]]; then
|
if [[ -z "$INFO_FLAG" ]]; then
|
||||||
dokku_log_info2 "$SERVICE $PLUGIN_COMMAND_PREFIX service information"
|
dokku_log_info2_quiet "$SERVICE $PLUGIN_COMMAND_PREFIX service information"
|
||||||
for flag in "${flag_map[@]}"; do
|
for flag in "${flag_map[@]}"; do
|
||||||
key="$(echo "${flag#--}" | cut -f1 -d' ' | tr - ' ')"
|
key="$(echo "${flag#--}" | cut -f1 -d' ' | tr - ' ')"
|
||||||
dokku_log_verbose "$(printf "%-20s %-25s" "${key^}" "${flag#*: }")"
|
dokku_log_verbose "$(printf "%-20s %-25s" "${key^}" "${flag#*: }")"
|
||||||
@@ -501,9 +522,7 @@ service_link() {
|
|||||||
|
|
||||||
[[ -n $LINK ]] && dokku_log_fail "Already linked as $LINK"
|
[[ -n $LINK ]] && dokku_log_fail "Already linked as $LINK"
|
||||||
plugn trigger service-action pre-link "$SERVICE" "$APP"
|
plugn trigger service-action pre-link "$SERVICE" "$APP"
|
||||||
touch "$LINKS_FILE"
|
add_to_links_file "$SERVICE" "$APP"
|
||||||
echo "$APP" >>"$LINKS_FILE"
|
|
||||||
sort "$LINKS_FILE" -u -o "$LINKS_FILE"
|
|
||||||
|
|
||||||
if declare -f -F add_passed_docker_option >/dev/null; then
|
if declare -f -F add_passed_docker_option >/dev/null; then
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
@@ -514,7 +533,11 @@ service_link() {
|
|||||||
fi
|
fi
|
||||||
[[ -n "$SERVICE_QUERYSTRING" ]] && SERVICE_URL="${SERVICE_URL}?${SERVICE_QUERYSTRING}"
|
[[ -n "$SERVICE_QUERYSTRING" ]] && SERVICE_URL="${SERVICE_URL}?${SERVICE_QUERYSTRING}"
|
||||||
plugn trigger service-action post-link "$SERVICE" "$APP"
|
plugn trigger service-action post-link "$SERVICE" "$APP"
|
||||||
|
if [[ "$DOKKU_GLOBAL_FLAGS" == *"--no-restart"* ]]; then
|
||||||
|
config_set --no-restart "$APP" "${ALIAS}_URL=$SERVICE_URL"
|
||||||
|
else
|
||||||
config_set "$APP" "${ALIAS}_URL=$SERVICE_URL"
|
config_set "$APP" "${ALIAS}_URL=$SERVICE_URL"
|
||||||
|
fi
|
||||||
plugn trigger service-action post-link-complete "$SERVICE" "$APP"
|
plugn trigger service-action post-link-complete "$SERVICE" "$APP"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,14 +582,14 @@ service_list() {
|
|||||||
|
|
||||||
service_logs() {
|
service_logs() {
|
||||||
declare desc="display logs for a service"
|
declare desc="display logs for a service"
|
||||||
declare SERVICE="$1" TAIL_FLAG="$2"
|
declare SERVICE="$1" TAIL_FLAG="$2" TAIL_COUNT="$3"
|
||||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
local ID=$(cat "$SERVICE_ROOT/ID")
|
local ID=$(cat "$SERVICE_ROOT/ID")
|
||||||
local RE_INTEGER='^[0-9]+$'
|
local RE_INTEGER='^[0-9]+$'
|
||||||
|
|
||||||
DOKKU_LOGS_ARGS="--tail 100"
|
DOKKU_LOGS_ARGS="--tail $TAIL_COUNT"
|
||||||
if [[ "$TAIL_FLAG" == "-t" ]] || [[ "$TAIL_FLAG" == "--tail" ]]; then
|
if [[ "$TAIL_FLAG" == "-t" ]] || [[ "$TAIL_FLAG" == "--tail" ]]; then
|
||||||
DOKKU_LOGS_ARGS="--follow"
|
DOKKU_LOGS_ARGS+=" --follow"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
||||||
@@ -838,7 +861,11 @@ service_unlink() {
|
|||||||
|
|
||||||
[[ -z ${LINK[*]} ]] && dokku_log_fail "Not linked to app $APP"
|
[[ -z ${LINK[*]} ]] && dokku_log_fail "Not linked to app $APP"
|
||||||
plugn trigger service-action post-unlink "$SERVICE" "$APP"
|
plugn trigger service-action post-unlink "$SERVICE" "$APP"
|
||||||
|
if [[ "$DOKKU_GLOBAL_FLAGS" == *"--no-restart"* ]]; then
|
||||||
|
config_unset --no-restart "$APP" "${LINK[@]}"
|
||||||
|
else
|
||||||
config_unset "$APP" "${LINK[@]}"
|
config_unset "$APP" "${LINK[@]}"
|
||||||
|
fi
|
||||||
plugn trigger service-action post-unlink-complete "$SERVICE" "$APP"
|
plugn trigger service-action post-unlink-complete "$SERVICE" "$APP"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
Note that the export will result in a file containing the binary postgres export data. It can be converted to plain text using `pg_restore` as follows
|
Note that the export will result in a file containing the binary postgres export data. It can be converted to plain text using `pg_restore` as follows
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pg_restore data.dump -f plain.sql.
|
pg_restore data.dump -f plain.sql
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -202,6 +202,9 @@ fn-help-subcommand-args() {
|
|||||||
elif [[ "$arg" == *_LIST ]]; then
|
elif [[ "$arg" == *_LIST ]]; then
|
||||||
arg=${arg%_*}
|
arg=${arg%_*}
|
||||||
args+=" <${arg//_/-}...>"
|
args+=" <${arg//_/-}...>"
|
||||||
|
elif [[ "$arg" == *_OPTIONAL ]]; then
|
||||||
|
argName="${arg/_OPTIONAL/}"
|
||||||
|
args+=" [<${argName//_/-}>]"
|
||||||
else
|
else
|
||||||
args+=" <${arg//_/-}>"
|
args+=" <${arg//_/-}>"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[plugin]
|
[plugin]
|
||||||
description = "dokku postgres service plugin"
|
description = "dokku postgres service plugin"
|
||||||
version = "1.14.0"
|
version = "1.19.0"
|
||||||
[plugin.config]
|
[plugin.config]
|
||||||
|
|||||||
19
post-app-clone-setup
Executable file
19
post-app-clone-setup
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions"
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/functions"
|
||||||
|
set -eo pipefail
|
||||||
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
plugin-post-app-clone-setup() {
|
||||||
|
declare OLD_APP_NAME="$1" NEW_APP_NAME="$2"
|
||||||
|
|
||||||
|
local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null)
|
||||||
|
for SERVICE in $SERVICES; do
|
||||||
|
if in_links_file "$SERVICE" "$OLD_APP_NAME"; then
|
||||||
|
add_to_links_file "$SERVICE" "$NEW_APP_NAME"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin-post-app-clone-setup "$@"
|
||||||
19
post-app-rename-setup
Executable file
19
post-app-rename-setup
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions"
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/functions"
|
||||||
|
set -eo pipefail
|
||||||
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
plugin-post-app-rename-setup() {
|
||||||
|
declare OLD_APP_NAME="$1" NEW_APP_NAME="$2"
|
||||||
|
|
||||||
|
local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null)
|
||||||
|
for SERVICE in $SERVICES; do
|
||||||
|
if in_links_file "$SERVICE" "$OLD_APP_NAME"; then
|
||||||
|
add_to_links_file "$SERVICE" "$NEW_APP_NAME"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin-post-app-rename-setup "$@"
|
||||||
36
pre-restore
Executable file
36
pre-restore
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions"
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/functions"
|
||||||
|
set -eo pipefail
|
||||||
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
plugin-pre-restore() {
|
||||||
|
declare SCHEDULER="$1" APP="$2"
|
||||||
|
|
||||||
|
if [[ "$SCHEDULER" != "docker-local" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null)
|
||||||
|
for SERVICE in $SERVICES; do
|
||||||
|
if ! in_links_file "$SERVICE" "$APP"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
local status="$(service_status "$SERVICE")"
|
||||||
|
if [[ "$status" == "running" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$status" == "restarting" ]]; then
|
||||||
|
dokku_log_warn "$PLUGIN_SERVICE service $SERVICE is restarting and may cause issues with linked app $APP"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
dokku_log_warn "$PLUGIN_SERVICE service $SERVICE is not running, issuing service start"
|
||||||
|
service_start "$SERVICE"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin-pre-restore "$@"
|
||||||
32
pre-start
Executable file
32
pre-start
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions"
|
||||||
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/functions"
|
||||||
|
set -eo pipefail
|
||||||
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
plugin-pre-start() {
|
||||||
|
declare APP="$1"
|
||||||
|
|
||||||
|
local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null)
|
||||||
|
for SERVICE in $SERVICES; do
|
||||||
|
if ! in_links_file "$SERVICE" "$APP"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
local status="$(service_status "$SERVICE")"
|
||||||
|
if [[ "$status" == "running" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$status" == "restarting" ]]; then
|
||||||
|
dokku_log_warn "$PLUGIN_SERVICE service $SERVICE is restarting and may cause issues with linked app $APP"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
dokku_log_warn "$PLUGIN_SERVICE service $SERVICE is not running, issuing service start"
|
||||||
|
service_start "$SERVICE"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin-pre-start "$@"
|
||||||
@@ -10,16 +10,18 @@ service-logs-cmd() {
|
|||||||
#E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop
|
#E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop
|
||||||
#E by default, logs will not be tailed, but you can do this with the --tail flag:
|
#E by default, logs will not be tailed, but you can do this with the --tail flag:
|
||||||
#E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop --tail
|
#E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop --tail
|
||||||
|
#E the default tail setting is to show all logs, but an initial count can also be specified
|
||||||
|
#E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop --tail 5
|
||||||
#A service, service to run command against
|
#A service, service to run command against
|
||||||
#F -t|--tail, do not stop when end of the logs are reached and wait for additional output
|
#F -t|--tail [<tail-num>], do not stop when end of the logs are reached and wait for additional output
|
||||||
declare desc="print the most recent log(s) for this service"
|
declare desc="print the most recent log(s) for this service"
|
||||||
local cmd="$PLUGIN_COMMAND_PREFIX:logs" argv=("$@")
|
local cmd="$PLUGIN_COMMAND_PREFIX:logs" argv=("$@")
|
||||||
[[ ${argv[0]} == "$cmd" ]] && shift 1
|
[[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||||
declare SERVICE="$1" TAIL_FLAG="$2"
|
declare SERVICE="$1" TAIL_FLAG="$2" TAIL_NUM_OPTIONAL="${3:-all}"
|
||||||
|
|
||||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
||||||
verify_service_name "$SERVICE"
|
verify_service_name "$SERVICE"
|
||||||
service_logs "$SERVICE" "$TAIL_FLAG"
|
service_logs "$SERVICE" "$TAIL_FLAG" "$TAIL_NUM_OPTIONAL"
|
||||||
}
|
}
|
||||||
|
|
||||||
service-logs-cmd "$@"
|
service-logs-cmd "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user