48 lines
1.3 KiB
Bash
48 lines
1.3 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
if [ ! -f "/etc/config/laconic.yml" ]; then
|
||
|
echo "/etc/config/laconic.yml is required."
|
||
|
exit 2
|
||
|
fi
|
||
|
|
||
|
if [ "$HANDLE_AUCTION_REQUESTS" = "true" ]; then
|
||
|
if [ -z "$AUCTION_BID_AMOUNT" ]; then
|
||
|
echo "AUCTION_BID_AMOUNT is required when handling auction requsts."
|
||
|
exit 2
|
||
|
fi
|
||
|
else
|
||
|
echo "Not handling auction requests"
|
||
|
|
||
|
# k8s integration only supports "always" restart policy, so wait indefinitely
|
||
|
# TODO: Exit container once restart policy is supported
|
||
|
tail -f /dev/null
|
||
|
fi
|
||
|
|
||
|
STORAGE_ROOT="${STORAGE_ROOT:-/srv}"
|
||
|
DEPLOYMENTS_DIR="${DEPLOYMENTS_DIR:-$STORAGE_ROOT/deployments}"
|
||
|
REGISTRY_LOCK_FILE="${REGISTRY_LOCK_FILE:-/srv/registry_mutex_lock_file}"
|
||
|
|
||
|
if [[ ! -d "${DEPLOYMENTS_DIR}" ]]; then
|
||
|
mkdir -p "${DEPLOYMENTS_DIR}"
|
||
|
fi
|
||
|
|
||
|
cd /app/
|
||
|
while true; do
|
||
|
echo "=============================================================="
|
||
|
|
||
|
echo "############ DEPLOYMENT AUCTION #############"
|
||
|
laconic-so handle-deployment-auction \
|
||
|
--laconic-config /etc/config/laconic.yml \
|
||
|
--registry-lock-file "${REGISTRY_LOCK_FILE}" \
|
||
|
--state-file "${DEPLOYMENTS_DIR}/autoauction.state" \
|
||
|
--bid-amount ${AUCTION_BID_AMOUNT}
|
||
|
rc=$?
|
||
|
if [ $rc -eq 0 ]; then
|
||
|
echo "############ DEPLOYMENT AUCTION SUCCESS #############"
|
||
|
else
|
||
|
echo "############ DEPLOYMENT AUCTION FAILURE STATUS $rc #############"
|
||
|
fi
|
||
|
|
||
|
sleep ${AUCTION_CHECK_INTERVAL:-10}
|
||
|
done
|