Sometimes simple scripts are the best scripts.
Here is a simple script I use to:
- Rebuild a "standing by" Discourse Docker container.
- Wait 60 seconds and display countdown timer while new container "spins up".
- Edit the apache2 configuration file in order to switch to the new container.
- Switch containers by restarting apache2.
- Display running docker containers after switching.
# cat /usr/local/bin/buildsocket
#!/bin/bash
/var/discourse/launcher rebuild socket-only
FROMHERE=60
echo -n "Countdown to container switch: "
for ((i=FROMHERE; i>=1; i--))
do
echo -n $i" "
sleep 1
done
sed -i.bak2 's/socket-only2\//socket-only\//' /etc/apache2/sites-available/community-le-ssl.conf
service apache2 restart
watch docker ps
This is how I rebuild Discourse Docker containers.
I have two of these simple scripts as opposed to reading the container details from the command line, so I don't accidentally fat finger something in a single, more generic, script:
/usr/local/bin/buildsocket
This script rebuilds the socket-only
container and replaces socket-only2
.
/usr/local/bin/buildsocket2
This script rebuilds the socket-only2
container and replaces socket-only
.
Most everyone loves screenshots:
When the switch is complete (from restarting Apache2) watch docker ps
is displayed, so we can see what is going on in the "container space".
This is a simple script which I use often these days.