Skip to content
Snippets Groups Projects
Commit ddd9a24f authored by Matt Ward's avatar Matt Ward
Browse files

Initial pass on a warm standby start/update tool


This is meant to allow us to start the warm standby and try to keep it up to date with changes published to the image.

Signed-off-by: default avatarmward <matt@eclipse.org>
parent 18445615
No related branches found
No related tags found
No related merge requests found
runme.sh 0 → 100755
#!/bin/bash
#*******************************************************************************
#* Copyright (c) 2022 onward Eclipse Foundation and others.
#* All rights reserved. This program and the accompanying materials
#* are made available under the terms of the Eclipse Public License v2.0
#* which accompanies this distribution, and is available at
#* http://www.eclipse.org/legal/epl-v20.html
#*
#* Contributors:
#* Matt Ward (Eclipse Foundation)
#*******************************************************************************/
umask 0022
#setup basic definitions
IMAGE="docker.io/eclipsefdn/www.eclipse.org:latest"
#podman should be a drop in replacement for docker
PODMAN="/usr/bin/podman"
CONTAINER_NAME="www-httpd"
RUNNING_IMAGE=""
LATEST_IMAGE=""
function pull_image {
# echo "Fetching $IMAGE"
$PODMAN pull -q $IMAGE
}
function get_image_id {
local IMAGE_ID=$($PODMAN history --format "{{.ID}}" $IMAGE | head -1)
echo $IMAGE_ID
}
function run_image {
# echo "Running Image $LATEST_IMAGE"
$PODMAN run --name=$CONTAINER_NAME -d -p 18181:8080 $LATEST_IMAGE
}
#main loop starts here.
pull_image
LATEST_IMAGE=$(get_image_id)
if [[ $RUNNING_IMAGE == "" ]]; then
# echo "Init setting RUNNING_IMAGE=LATEST_IMAGE"
RUNNING_IMAGE=$LATEST_IMAGE
fi
run_image
while :
do
sleep 300;
#pull and get the image id
pull_image
LATEST_IMAGE=$(get_image_id)
if [[ $RUNNING_IMAGE != $LATEST_IMAGE ]]; then
echo "Latest image id is not the running image, restarting"
$PODMAN stop $CONTAINER_NAME
$PODMAN rm $CONTAINER_NAME
run_image
RUNNING_IMAGE=$LATEST_IMAGE
fi
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment