forked from tursodatabase/libsql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·40 lines (30 loc) · 1014 Bytes
/
docker-entrypoint.sh
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
#!/bin/bash
set -Eeuo pipefail
SQLD_NODE="${SQLD_NODE:-primary}"
SQLD_DB_PATH="${SQLD_DB_PATH:-iku.db}"
SQLD_PG_LISTEN_ADDR="${SQLD_PG_LISTEN_ADDR:-"0.0.0.0:5432"}"
SQLD_HTTP_LISTEN_ADDR="${SQLD_HTTP_LISTEN_ADDR:-"0.0.0.0:8080"}"
SQLD_HTTP_AUTH="${SQLD_HTTP_AUTH:-"always"}"
if [ "$1" = '/bin/sqld' ]; then
# We are running the server.
declare -a server_args=()
server_args+=("--db-path" "$SQLD_DB_PATH")
# Listen on HTTP 8080 port by default.
server_args+=("--http-listen-addr" "$SQLD_HTTP_LISTEN_ADDR")
server_args+=("--http-auth" "$SQLD_HTTP_AUTH")
# Set remaining arguments depending on what type of node we are.
case "$SQLD_NODE" in
primary)
SQLD_GRPC_LISTEN_ADDR="${SQLD_GRPC_LISTEN_ADDR:-"0.0.0.0:5001"}"
server_args+=("--grpc-listen-addr" "$SQLD_GRPC_LISTEN_ADDR")
;;
replica)
server_args+=("--primary-grpc-url" "$SQLD_PRIMARY_URL")
;;
standalone)
;;
esac
# Append server arguments.
set -- "$@" ${server_args[@]}
fi
exec "$@"