blob: 68b250c0e064343e137619479d73e6cb90dfe343 [file] [log] [blame]
Miroslav Zagorac70230c62020-12-09 16:54:31 +01001#!/bin/sh
2#
3_ARG_HAPROXY="${1:-$(realpath -L ${PWD}/../../../haproxy)}"
4 _ARGS_FE="-f fe/haproxy.cfg"
5 _ARGS_BE="-f be/haproxy.cfg"
6 _TIME="$(date +%s)"
7 _LOG_DIR="_logs"
Miroslav Zagorac1bd02222022-03-09 17:34:11 +01008 _LOG_FE="${_LOG_DIR}/_log-$(basename "${0}" fe-be.sh)fe-${_TIME}"
9 _LOG_BE="${_LOG_DIR}/_log-$(basename "${0}" fe-be.sh)be-${_TIME}"
Miroslav Zagorac70230c62020-12-09 16:54:31 +010010
11
12__exit ()
13{
14 test -z "${2}" && {
15 echo
16 echo "Script killed!"
17
18 echo "Waiting for jobs to complete..."
19 pkill --signal SIGUSR1 haproxy
20 wait
21 }
22
23 test -n "${1}" && {
24 echo
25 echo "${1}"
26 echo
27 }
28
29 exit ${2:-100}
30}
31
32
33trap __exit INT TERM
34
35test -x "${_ARG_HAPROXY}" || __exit "${_ARG_HAPROXY}: executable does not exist" 1
36mkdir -p "${_LOG_DIR}" || __exit "${_ARG_HAPROXY}: cannot create log directory" 2
37
38echo "\n------------------------------------------------------------------------"
39echo "--- executing: ${_ARG_HAPROXY} ${_ARGS_BE} > ${_LOG_BE}"
40"${_ARG_HAPROXY}" ${_ARGS_BE} >"${_LOG_BE}" 2>&1 &
41
42echo "--- executing: ${_ARG_HAPROXY} ${_ARGS_FE} > ${_LOG_FE}"
43"${_ARG_HAPROXY}" ${_ARGS_FE} >"${_LOG_FE}" 2>&1 &
44echo "------------------------------------------------------------------------\n"
45
46echo "Press CTRL-C to quit..."
47wait