-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·51 lines (40 loc) · 894 Bytes
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
set -e
if [ -z "$1" ]; then
echo "The server argument must be set."
exit 1
fi
if [ -z "$2" ]; then
echo "The concurrency argument must be set."
exit 1
fi
if [ "$LOG_ADDRESS" ]; then
LOG="log $LOG_ADDRESS format rfc5424 local0"
if [ "$LOG_FORMAT" ]; then
LOG_FORMAT="log-format \"${LOG_FORMAT}\""
else
LOG_FORMAT="option httplog"
fi
fi
cat <<EOF > /usr/local/etc/haproxy/haproxy.cfg
global
maxconn ${MAX_CONNECTIONS:-2000}
defaults
mode http
timeout connect 5s
timeout client 30s
timeout server ${SERVER_TIMEOUT:-30s}
timeout queue ${QUEUE_TIMEOUT:-5s}
frontend http
bind *:${PORT:-8000}
acl is_healthcheck path ${HEALTHCHECK_PATH:-/healthcheck}
use_backend healthcheck if is_healthcheck
default_backend app
$LOG
$LOG_FORMAT
backend app
server main $1 maxconn $2
backend healthcheck
server main $1
EOF
haproxy -f /usr/local/etc/haproxy/haproxy.cfg