Gohang
To make a go program hang until terminated, you can use this line:
<-make(chan struct{})
Why would you want to do this? In our case we have a blue/green setup that and docker compose set to restart: always
, so if the server reboots both the blue and green containers get spun up at the same time. Now we check to see which one is supposed to be active, and if a container doesn’t match, it executes this hang - otherwise docker will see the 0 exit code and constantly try restarting the container.