multi node flask web server
2024-10-05
Today's effort was in several phases. Implementing a session state server in flask using reddis. Next I spent a couple hours troubleshooting an EFS network issue. As it turns out there was a network security group on the efs share that needed good listing. The next step was getting a second container hosting the website running. I settled on having one docker container running on the default port and one running on 8081. The next problem was that of load balancing the public face of the website. After some trial and error I settled on the built in apache load balancer. After a couple hours of trying different things I finally got it working. The last step was to update the deployment scripts handle having multiple containers running.
Today's effort was in several phases. Implementing a session state server in flask using reddis. Next I spent a couple hours troubleshooting an EFS network issue. As it turns out there was a network security group on the efs share that needed good listing. The next step was getting a second container hosting the website running. I settled on having one docker container running on the default port and one running on 8081. The next problem was that of load balancing the public face of the website. After some trial and error I settled on the built in apache load balancer. After a couple hours of trying different things I finally got it working. The last step was to update the deployment scripts handle having multiple containers running.
#!/bin/bash
#Check if we have a parameter
if [ $# -eq 1 ]; then
#check if the parameter is a file that exists
if [ -f "$1" ]; then
unzip -o "$1"
rm "$1"
fi
fi
oldimage=$(docker images | grep -w vacuumflask | awk '{print $3}')
newimageid=$(sh build.sh | awk '{print $4}')
runninginstance=$(docker ps | grep -w "$oldimage" | awk '{print $1}')
#echo "running instances: $runningistance"
while IFS= read -r instance; do
docker kill "$instance"
done <<< "$runninginstance"
sh run.sh
sh run2.sh
nowrunninginstance=$(docker ps | grep -w "$newimageid" | awk '{print $1}')
docker ps
echo "new running instance id is: $nowrunninginstance"
docker run --name some-redis -d -p 6379:6379 redis
