forked from sehrope/dokku-logging-supervisord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands
executable file
·52 lines (44 loc) · 1.14 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
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
PLUGIN_DIR=$(dirname $0)
. "$PLUGIN_DIR/lib/helpers"
case "$1" in
scale)
if [[ -z $2 ]]; then
echo "Please specify an app to scale"
exit 1
fi
APP="$2"
IMAGE="dokku/$APP"
REPO="$DOKKU_ROOT/$APP"
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" /SCALE
dokku deploy "$APP"
;;
help)
cat && cat<<EOF
scale <app> TYPE1=NUM1 [TYPE2=NUM2 ...] Scale an app
EOF
;;
esac