Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #43 from servicecatalog/locking
Browse files Browse the repository at this point in the history
Locking
  • Loading branch information
Frank Shimizu committed Feb 1, 2018
2 parents 2117178 + 6254bf6 commit 4243761
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
17 changes: 17 additions & 0 deletions chef/cookbooks/escm/files/default/user-data/deploy-escmserver
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set -e

# Variables for this script
CONFIG_BASE=/etc/escm
LOCK_FILE=${CONFIG_BASE}/deploy-escmserver.lock
SSL_CONFIG_PATH=${CONFIG_BASE}/ssl
COMPOSE_CONFIG_PATH=${CONFIG_BASE}/docker-compose
DOCKER_PATH=/docker
Expand All @@ -21,6 +22,14 @@ exec &>> ${DOCKER_PATH}/logs/setup-machine-$(date '+%Y-%m-%d').log

echo "$(date '+%Y-%m-%d %H:%M:%S') starting setup..."

# Check whether another instance of this script is already running
if [ ! -f ${LOCK_FILE} ]; then
touch ${LOCK_FILE}
else
echo "$(date '+%Y-%m-%d %H:%M:%S') lock file is already present - aborting..."
exit 0
fi

# Check if update is necessary
if [ -f ${DOCKER_PATH}/var.env.old ]; then
if [ $(diff ${DOCKER_PATH}/var.env.old ${COMPOSE_CONFIG_PATH}/var.env | wc -l) == "0" ]; then
Expand All @@ -36,6 +45,7 @@ fi

if [ ${UPDATE_NECESSARY_CONFIG} == "false" ] && [ ${UPDATE_NECESSARY_CERTS} == "false" ]; then
echo "$(date '+%Y-%m-%d %H:%M:%S') configuration not changed - aborting..."
rm -f ${LOCK_FILE}
exit 0
fi

Expand All @@ -50,6 +60,7 @@ set +a
# If mandatory variables are unset, abort
if [ -z ${DB_PWD_CORE} ] || [ -z ${DB_PWD_APP} ] || [ -z ${KEY_SECRET} ] || [ -z ${HOST_FQDN} ] || [ -z ${DB_SUPERPWD} ]; then
echo "$(date '+%Y-%m-%d %H:%M:%S') Mandatory variables unset - aborting."
rm -f ${LOCK_FILE}
exit 0
fi

Expand Down Expand Up @@ -150,6 +161,9 @@ if [ -f ${COMPOSE_CONFIG_PATH}/var.env ]; then
cp ${COMPOSE_CONFIG_PATH}/var.env ${DOCKER_PATH}
fi

# Pull latest deployer image
docker pull ${IMAGE_DEPLOYER}

# Create Docker directory structure and Docker Compose files
pushd ${DOCKER_PATH}
docker run --name deployer-directories-compose --rm -v ${DOCKER_PATH}:/target ${IMAGE_DEPLOYER}
Expand Down Expand Up @@ -182,4 +196,7 @@ docker run --name deployer-init-start --rm -v ${DOCKER_PATH}:/target -v /var/run
# Backup the current configuration for update check by the next run
cp ${DOCKER_PATH}/var.env ${DOCKER_PATH}/var.env.old

# Remove lock file
rm -f ${LOCK_FILE}

echo "$(date '+%Y-%m-%d %H:%M:%S') setup finished."
4 changes: 2 additions & 2 deletions chef/cookbooks/escm/recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@
db_pwd_app: var_db_pwd_app,
db_superpwd: var_db_superpwd,
os_keystone_url: keystone_settings["public_auth_url"],
os_user: keystone_settings["admin_user"],
os_password: keystone_settings["admin_password"],
os_user: escm_user,
os_password: escm_password,
os_domain: keystone_settings["admin_domain"]
)
end
Expand Down
4 changes: 4 additions & 0 deletions chef/cookbooks/escm/templates/default/.env.erb
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ IMAGE_DEPLOYER=<%= @docker["host"]+":"+@docker["port"].to_s+"/"+@docker["organiz
<% end %>

DOCKER_PATH=/docker

# HTTP Timeout for Docker Compose: Increase this if you get timeout errors
# during high load or network congestion. Default=60
COMPOSE_HTTP_TIMEOUT=600

0 comments on commit 4243761

Please sign in to comment.