-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathboot
More file actions
executable file
·35 lines (28 loc) · 889 Bytes
/
boot
File metadata and controls
executable file
·35 lines (28 loc) · 889 Bytes
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
#!/bin/bash
#
# This script is designed to be run inside the container
#
# fail hard and fast even on pipelines
set -eo pipefail
# check for required variables
: ${PUBLIC_IP:?"PUBLIC_IP environment variable required"}
export PUBLIC_IP=$PUBLIC_IP
# set etcd variable defaults
export ETCD_PORT=${ETCD_PORT:-4001}
export ETCD_PEER_PORT=${ETCD_PEER_PORT:-7001}
export ETCD_NODE_NAME=${ETCD_NODE_NAME:-$(hostname)}
# spawn the service in the background
$(dirname ${BASH_SOURCE[0]})/start &
SERVICE_PID=$!
# smart shutdown on SIGINT and SIGTERM
function on_exit() {
kill -TERM $SERVICE_PID
wait $SERVICE_PID 2>/dev/null
}
trap on_exit INT TERM
# wait for the service to become available
HOST=${HOST:-localhost}
PORT=${PORT:-4001}
PROTO=${PROTO:-tcp}
sleep 1 && while ! $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PORT\" && \$1 ~ \"$PROTO.\"" >/dev/null) ; do sleep 1; done
wait