#!/bin/bash

CIRCUS_UP=1
pgrep -f "circusd ${MFMODULE_RUNTIME_HOME}/tmp/config_auto/circus.ini" >/dev/null 2>&1 || CIRCUS_UP=0
if test "${CIRCUS_UP}" = "0"; then
    # if circus is down, no need to wait circusctl timeout
    echo "error"
    exit 1
fi

# because of https://github.com/circus-tent/circus/issues/962

# shellcheck disable=SC1091
. "${MFEXT_HOME}/lib/bash_utils.sh"
layer_load python3_circus@mfext >/dev/null 2>&1

python -m circus.circusctl "$@"
