-
Notifications
You must be signed in to change notification settings - Fork 34
/
commands
executable file
·66 lines (54 loc) · 1.39 KB
/
commands
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$2"
IMAGE="dokku/$APP"
REPO="$DOKKU_ROOT/$APP"
PLUGIN_DIR=$(dirname $0)
. "$PLUGIN_DIR/lib/helpers"
case "$1" in
scale)
[[ -z $2 ]] && echo "Please specify an app to scale" && exit 1
if [[ -n $DOKKU_API_VERSION ]]; then
source "$PLUGIN_ENABLED_PATH/common/functions"
IMAGE=$(get_app_image_name $APP)
fi
if [ ! -d "$REPO" ]; then
echo "No matching app: $APP"
exit 1
fi
shift 2
# TODO: Copy to a temp file first
# TODO: Validate that it is of the form name=num
SCALEFILE="$REPO/SCALE"
for line in "$@"
do
echo "$line"
done > "$SCALEFILE"
# kill the app when running
echo "Checking for existing running application"
if [[ -f "$DOKKU_ROOT/$APP/CONTAINER" ]]; then
echo "Existing running application found. Will kill it."
oldid=$(< "$DOKKU_ROOT/$APP/CONTAINER")
docker kill $oldid > /dev/null 2>&1 || true
echo "Killed running application."
fi
echo "Scaling app $APP:"
cat -n "$REPO/SCALE"
copy_to_container "$SCALEFILE" /app/SCALE
dokku deploy "$APP"
;;
help)
HELP=$(cat<<EOF
scale <app> TYPE1=NUM1 [TYPE2=NUM2 ...], Scale an app
EOF
)
if [[ -n $DOKKU_API_VERSION ]]; then
echo "$HELP"
else
cat && echo "$HELP"
fi
;;
*)
exit $DOKKU_NOT_IMPLEMENTED_EXIT
;;
esac