test $# -lt 2 && echo -e "error: too few arguments\n\n\e[1mUSAGE\e[0m\n\tmaster <key> <host> <port> <dir>\n\n\e[1mARGUMENTS\e[0m\n\t<key>\tThe key of the pool\n\t<host>\tThe host where the pool is hosted\n\t<port>\tTo port where the pool is bound\n\t<dir>\tThe folder containing ONLY the logger daemons\n" && exit 1;
# (3) Check @PORT range #
MIN_PORT=1024;
MAX_PORT=49151;
test "$3" -gt "$MAX_PORT" -o "$3" -lt "$MIN_PORT" && echo "error: <port> must be between $MIN_PORT and $MAX_PORT" && exit 1;
# (4) Set argument explicit names #
POOL_KEY="$1";
POOL_HOST="$2";
POOL_PORT="$3";
LOGGER_DIR="`realpath $4`";
# (5) Check @LOGGER_DIR #
test ! -d "$LOGGER_DIR" && echo "error: <dir> is not a valid folder." && exit 1;
# (6) init logger variables #
declare -A OUTPUT_PID; # will contain each bind-output PIDs
declare -A LOGGER_PID; # will contain each logger PIDs
# (7) get logger list #
LOGGERS=(`ls $LOGGER_DIR`);
# (8) If no logger -> exit #
test "${#LOGGERS[@]}" -eq 0 && echo "error: no logger found in <dir>." && exit 1;