forked from SingularitiesCR/datastore-emulator-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-datastore
executable file
·46 lines (41 loc) · 1.02 KB
/
start-datastore
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
#!/usr/bin/env bash
# Check user environment variable
if [[ -z "${DATASTORE_PROJECT_ID}" ]]; then
echo "Missing DATASTORE_PROJECT_ID environment variable" >&2
exit 1
fi
if [[ -z "${DATASTORE_LISTEN_ADDRESS}" ]]; then
echo "Missing DATASTORE_LISTEN_ADDRESS environment variable" >&2
exit 1
fi
options=${options:1}
# Check for datastore options
while [ ! $# -eq 0 ]
do
case "$1" in
--store-on-disk)
options="$options --store-on-disk"
shift
;;
--no-store-on-disk)
options="$options --no-store-on-disk"
shift
;;
--consistency=*)
consistency=${1#*=}
options="$options --consistency=$consistency"
shift
;;
*)
echo "Invalid option: $1. Use: --store-on-disk, --no-store-on-disk, --consistency=[0.0-1.0]"
exit 1
;;
esac
done
# Config gcloud project
gcloud config set project ${DATASTORE_PROJECT_ID}
# Start emulator
gcloud beta emulators datastore start \
--data-dir=/opt/data \
--host-port=${DATASTORE_LISTEN_ADDRESS} \
${options}