Skip to content

Commit

Permalink
Merge branch 'hotfix-2.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
patternhelloworld committed Sep 6, 2023
2 parents 2339dd5 + 2ee4d9a commit 7e20f3d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .docker/nginx/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ nginx_client_max_body_size=$(printenv NGINX_CLIENT_MAX_BODY_SIZE)
echo "[NOTICE] In case the original file './docker/nginx/logrotate' has CRLF. That causes errors to Logrotate. So replacing CRLF to LF"
sed -i -e 's/\r$//' /etc/logrotate.d/nginx || echo "[NOTICE] Failed in replacing CRLF to LF, but it is a minor error, we continue the process."

echo "[NOTICE] Create base log files."
touch /var/log/nginx/access.log
touch /var/log/nginx/error.log
echo "[NOTICE] Give safe permissions to '/var/log/nginx'."
chown -R www-data /var/log/nginx


#echo "[NOTICE] Start Logrotate for logging Nginx (Access, Error) logs"
#echo "59 23 * * * /usr/sbin/logrotate /etc/logrotate.conf" >> /etc/crontab
Expand Down
18 changes: 16 additions & 2 deletions activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sudo sed -i -e "s/\r$//g" $(basename $0)
source ./util.sh

#cache_global_vars
project_name=$(get_value_from_env "PROJECT_NAME")
cache_non_dependent_global_vars

new_state=$1
old_state=$2
Expand Down Expand Up @@ -52,7 +52,21 @@ while [ 1 ]; do
count=$((count + 1))
if [[ ${count} -eq 10 ]]; then
echo "[WARNING] Since ${new_upstream} string is not found in the NGINX configuration file, we will revert CONSUL to ${old_state} (although it should already be ${old_state}, we will save it again to ensure)"
./reset.sh ${consul_key_value_store} ${old_state} ${new_state}
is_run=$(docker exec ${project_name}-${old_state} echo 'yes' 2>/dev/null || echo 'no')
if [[ ${is_run} == 'yes' ]]; then
if [[ $(check_availability_inside_container_speed_mode 'blue' 10 5 | tail -n 1) == 'true' ]]; then
is_run='yes'
else
is_run='no'
fi
fi

if [[ ${is_run} == 'yes' ]]; then
./reset.sh ${consul_key_value_store} ${old_state} ${new_state}
else
echo "[WARNING] We won't revert, as ${old_state} is NOT running as well."
fi

exit 1
fi
echo 'Wait for the new configuration'
Expand Down
2 changes: 1 addition & 1 deletion remove-all-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ git config core.filemode false
sleep 3
source ./util.sh

cache_project_info
cache_non_dependent_global_vars

echo "[NOTICE] Delete all containers and networks related to the project. Ignore any error messages that may appear if the items do not exist."

Expand Down
2 changes: 1 addition & 1 deletion stop-all-containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ git config core.filemode false
sleep 3
source ./util.sh

cache_project_info
cache_non_dependent_global_vars

echo "[NOTICE] Delete all containers and networks related to the project. Ignore any error messages that may appear if the items do not exist."

Expand Down
25 changes: 16 additions & 9 deletions util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ cache_all_states() {
echo "[NOTICE] ${new_state} will be running."
}

cache_project_info() {
cache_non_dependent_global_vars() {
project_name=$(get_value_from_env "PROJECT_NAME")
app_env=$(get_value_from_env "APP_ENV")
project_location=$(get_value_from_env "PROJECT_LOCATION")
project_port=$(get_value_from_env "PROJECT_PORT")
app_url=$(get_value_from_env "APP_URL")
protocol=$(echo ${app_url} | awk -F[/:] '{print $1}')
app_health_check_path=$(get_value_from_env "APP_HEALTH_CHECK_PATH")
bad_app_health_check_pattern=$(get_value_from_env "BAD_APP_HEALTH_CHECK_PATTERN")
good_app_health_check_pattern=$(get_value_from_env "GOOD_APP_HEALTH_CHECK_PATTERN")
}

cache_global_vars() {
Expand Down Expand Up @@ -285,8 +292,8 @@ server {
}
access_log /var/log/nginx/access.log combined;
error_log /var/log/nginx/error.log notice;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
EOF

Expand Down Expand Up @@ -320,8 +327,8 @@ server {
proxy_connect_timeout 75s;
}
access_log /var/log/nginx/access.log combined;
error_log /var/log/nginx/error.log notice;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
EOF
done
Expand Down Expand Up @@ -367,8 +374,8 @@ server {
}
access_log /var/log/nginx/access.log combined;
error_log /var/log/nginx/error.log notice;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
EOF

Expand Down Expand Up @@ -410,8 +417,8 @@ server {
}
access_log /var/log/nginx/access.log combined;
error_log /var/log/nginx/error.log notice;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
EOF
done
Expand Down

0 comments on commit 7e20f3d

Please sign in to comment.