forked from vyctorbh/docker-shipyard-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·34 lines (33 loc) · 1 KB
/
run.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
#!/bin/bash
REDIS_HOST=${REDIS_PORT_6379_TCP_ADDR:-$REDIS_HOST}
REDIS_HOST=${REDIS_HOST:-127.0.0.1}
REDIS_PORT=${REDIS_PORT_6379_TCP_PORT:-$REDIS_PORT}
REDIS_PORT=${REDIS_PORT:-6379}
ROUTER_CONFIG=/etc/shipyard_router.config.json
ROUTER_WORKERS=${ROUTER_WORKERS:-5}
ROUTER_MAX_SOCKETS=${ROUTER_MAX_SOCKETS:-100}
ROUTER_DEAD_BACKEND_TTL=${ROUTER_DEAD_BACKEND_TTL:-30}
ROUTER_HTTP_PORT=${ROUTER_HTTP_PORT:-80}
LOG_DIR=/var/log/shipyard
mkdir -p $LOG_DIR
# check for fig env
if [ ! -z "$SHIPYARD_REDIS_1_PORT_6379_TCP_ADDR" ]; then
REDIS_HOST=$SHIPYARD_REDIS_1_PORT_6379_TCP_ADDR
REDIS_PORT=$SHIPYARD_REDIS_1_PORT_6379_TCP_PORT
fi
# hipache config
cat << EOF > $ROUTER_CONFIG
{
"server": {
"accessLog": "/var/log/shipyard/router.log",
"port": $ROUTER_HTTP_PORT,
"workers": $ROUTER_WORKERS,
"maxSockets": $ROUTER_MAX_SOCKETS,
"deadBackendTTL": $ROUTER_DEAD_BACKEND_TTL
},
"redisHost": "$REDIS_HOST",
"redisPort": $REDIS_PORT
}
EOF
# run
hipache -c $ROUTER_CONFIG