Your Name 09035aa2aa Tidy
2025-04-25 17:58:31 +12:00

30 lines
961 B
Bash
Executable File

#!/bin/bash
source "$(dirname "$0")/_common.sh"
SERVICE_CONFIG_DIR="$1"
load_env "$SERVICE_CONFIG_DIR" || die "Failed to load environment variables"
# Required environment variables
check_required_env_vars "CONTAINER_NAME" "INTERVAL"
DOCKER_RUN_CMD="docker run -d \
--restart unless-stopped \
--name ${CONTAINER_NAME} \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${SERVICE_CONFIG_DIR}/config.json:/config.json
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG} \
--interval ${INTERVAL}"
if ! create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
echo "RUN_CMD failed:"
echo "$DOCKER_RUN_CMD"
die "Failed to start container ${CONTAINER_NAME}"
fi
# Check if the container is running
if ! _is_container_running "$CONTAINER_NAME"; then
die "Container ${CONTAINER_NAME} is not running"
fi
echo "Container ${CONTAINER_NAME} started"