All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 47s
32 lines
711 B
Bash
Executable File
32 lines
711 B
Bash
Executable File
#!/bin/bash
|
|
source "${AGENT_PATH}/common.sh"
|
|
_check_required_env_vars "CONTAINER_NAME"
|
|
|
|
# STATUS SCRIPT
|
|
# The status script is REQUIRED.
|
|
# It is used to return the status of the service.
|
|
# Must output exactly one of: Running, Stopped, Error, Unknown
|
|
|
|
# Check if container exists
|
|
if ! docker ps -a --format "{{.Names}}" | grep -q "^${CONTAINER_NAME}$"; then
|
|
echo "Unknown"
|
|
exit 0
|
|
fi
|
|
|
|
# Check container state
|
|
STATE=$(docker inspect -f '{{.State.Status}}' "$CONTAINER_NAME" 2>/dev/null)
|
|
case "$STATE" in
|
|
running)
|
|
echo "Running"
|
|
;;
|
|
exited|stopped)
|
|
echo "Stopped"
|
|
;;
|
|
restarting|paused)
|
|
echo "Error"
|
|
;;
|
|
*)
|
|
echo "Unknown"
|
|
;;
|
|
esac
|