Skip to content

Commit f1d60d6

Browse files
committed
fix: start linked datastores when an app is started or restored
This won't _also_ fix issues when an app is deployed as there isn't an exposed hook for it, but it should fix many other issues. For the app deployment problem, we'll need a new hook upstream. Refs dokku/dokku-redis#138
1 parent 32fdea9 commit f1d60d6

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

pre-restore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
3+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions"
4+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/functions"
5+
set -eo pipefail
6+
[[ $DOKKU_TRACE ]] && set -x
7+
8+
plugin-pre-restore() {
9+
declare SCHEDULER="$1" APP="$2"
10+
11+
if [[ "$SCHEDULER" != "docker-local" ]]; then
12+
return
13+
fi
14+
15+
local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null)
16+
for SERVICE in $SERVICES; do
17+
if ! in_links_file "$SERVICE" "$APP"; then
18+
continue
19+
fi
20+
21+
local status="$(service_status "$SERVICE")"
22+
if [[ "$status" == "running" ]]; then
23+
continue
24+
fi
25+
26+
if [[ "$status" == "restarting" ]]; then
27+
dokku_log_warn "$PLUGIN_SERVICE service $SERVICE is restarting and may cause issues with linked app $APP"
28+
continue
29+
fi
30+
31+
dokku_log_warn "$PLUGIN_SERVICE service $SERVICE is not running, issuing service start"
32+
service_start "$SERVICE"
33+
done
34+
}
35+
36+
plugin-pre-restore "$@"

pre-start

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config"
3+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common-functions"
4+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/functions"
5+
set -eo pipefail
6+
[[ $DOKKU_TRACE ]] && set -x
7+
8+
plugin-pre-start() {
9+
declare APP="$1"
10+
11+
local SERVICES=$(ls "$PLUGIN_DATA_ROOT" 2>/dev/null)
12+
for SERVICE in $SERVICES; do
13+
if ! in_links_file "$SERVICE" "$APP"; then
14+
continue
15+
fi
16+
17+
local status="$(service_status "$SERVICE")"
18+
if [[ "$status" == "running" ]]; then
19+
continue
20+
fi
21+
22+
if [[ "$status" == "restarting" ]]; then
23+
dokku_log_warn "$PLUGIN_SERVICE service $SERVICE is restarting and may cause issues with linked app $APP"
24+
continue
25+
fi
26+
27+
dokku_log_warn "$PLUGIN_SERVICE service $SERVICE is not running, issuing service start"
28+
service_start "$SERVICE"
29+
done
30+
}
31+
32+
plugin-pre-start "$@"

0 commit comments

Comments
 (0)