Skip to content

Commit

Permalink
fix : create network first for consul
Browse files Browse the repository at this point in the history
  • Loading branch information
patternhelloworld committed Nov 13, 2023
1 parent 5808444 commit 03d9830
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
To deploy web projects must be [simple and safe](https://github.com/Andrew-Kang-G/docker-blue-green-runner#emergency).

- [NOTICE]
- 'ORCHESTRATION_TYPE=stack' is currently experimental, keep 'ORCHESTRATION_TYPE=compose' as it is in the production stage.
- However, you would test the docker swarm, run the command. It is currently tested for the Java sample.
- ```shell
docker swarm init
sudo bash run.sh
```

## Introduction

Expand Down Expand Up @@ -377,4 +370,13 @@ sudo bash run-and-kill-jar-and-state-is-restarting-or-running.sh

## Concurrent Running for this App
- Running ```sudo bash *.sh``` concurrently for the **same** project at the same time, is NOT safe.
- Running ```sudo bash *.sh``` concurrently for **different** projects at the same time, is safe.
- Running ```sudo bash *.sh``` concurrently for **different** projects at the same time, is safe.

## Docker Swarm

- 'ORCHESTRATION_TYPE=stack' is currently experimental, keep 'ORCHESTRATION_TYPE=compose' as it is in the production stage.
- However, you would test the docker swarm, run the command. It is currently tested for the Java sample.
- ```shell
docker swarm init
sudo bash run.sh
```
17 changes: 9 additions & 8 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ terminate_whole_system(){
load_all_containers(){
# app, consul, nginx
# In the past, restarting Nginx before App caused error messages like "upstream not found" in the Nginx configuration file. This seems to have caused a 502 error on the socket side.
# Therefore, it is safer to restart the containers in the order of Consul -> App -> Nginx.
if [[ ${consul_restart} == 'true' ]]; then

consul_down_and_up

fi

echo "[NOTICE] Creating consul network..."
if [[ ${orchestration_type} != 'stack' ]]; then
Expand All @@ -115,6 +109,13 @@ load_all_containers(){
docker network create --driver overlay consul || echo "[NOTICE] Consul Network has already been created. You can ignore this message."
fi

# Therefore, it is safer to restart the containers in the order of Consul -> App -> Nginx.
if [[ ${consul_restart} == 'true' ]]; then

consul_down_and_up

fi


echo "[NOTICE] Run the app as a ${new_state} container. (As long as NGINX_RESTART is set to 'false', this won't stop the running container since this is a BLUE-GREEN deployment.)"
app_down_and_up
Expand Down Expand Up @@ -211,10 +212,10 @@ _main() {
if [[ ${skip_building_app_image} != 'true' ]]; then
load_app_docker_image
fi
if [ ${consul_restart} == 'true' ]; then
if [[ ${consul_restart} == 'true' ]]; then
load_consul_docker_image
fi
if [ ${nginx_restart} == 'true' ]; then
if [[ ${nginx_restart} == 'true' ]]; then
load_nginx_docker_image
fi

Expand Down

0 comments on commit 03d9830

Please sign in to comment.