diff --git a/zato/actions/.renew_crt.swp b/zato/actions/.renew_crt.swp new file mode 100644 index 0000000..580885a Binary files /dev/null and b/zato/actions/.renew_crt.swp differ diff --git a/zato/actions/renew_crt b/zato/actions/renew_crt index 6b7c6c2..2fbe42f 100755 --- a/zato/actions/renew_crt +++ b/zato/actions/renew_crt @@ -9,3 +9,15 @@ DOMAIN=$(relation:get "$SERVICE_NAME":web-proxy domain) merge_crt_letsencrypt "$DOMAIN" || exit 1 + +zato_commands=" +cd /opt/zato && +./restart-load-balancer.sh +" + +if ! exec_as_zato_in_container "$zato_commands"; then + printf "Error: failed to execute 'restart-load-balancer' in container '%s'.\n" "$CONTAINER_NAME" >&2 + return 1 +fi + +echo "load balancer restarted" diff --git a/zato/hooks/.init.swp b/zato/hooks/.init.swp new file mode 100644 index 0000000..4bb0935 Binary files /dev/null and b/zato/hooks/.init.swp differ diff --git a/zato/hooks/init b/zato/hooks/init index 1123a45..2060b0b 100755 --- a/zato/hooks/init +++ b/zato/hooks/init @@ -22,6 +22,8 @@ DATASTORE_ZATO_DIR="$SERVICE_NAME$ZATO_DIR" SSH_PASSWORD_FILE="$SERVICE_DATASTORE"/.compose/password/ssh-password DASHBOARD_PASSWORD_FILE="$SERVICE_DATASTORE"/.compose/password/dashboard-password IDE_PASSWORD_FILE="$SERVICE_DATASTORE"/.compose/password/ide-password +## Load balancer script in not in /opt/zato/env/qs-1 because this folder is created after launch +RESTART_LOADBALANCER_FILE=/opt/zato/restart-load-balancer.sh ssh_password=$(generate_or_get_secret "$SSH_PASSWORD_FILE") dashboard_password=$(generate_or_get_secret "$DASHBOARD_PASSWORD_FILE") @@ -36,6 +38,8 @@ $SERVICE_NAME: Zato_SSH_Password: \"$ssh_password\" Zato_Dashboard_Password: \"$dashboard_password\" Zato_IDE_Password: \"$ide_password\" + volumes: + - /srv/charm-store/elabore-charms/zato/resources$RESTART_LOADBALANCER_FILE:$RESTART_LOADBALANCER_FILE " # uid=$(docker_get_uid "$SERVICE_NAME" "zato") diff --git a/zato/lib/common b/zato/lib/common index 0e5d8f6..5a5a4ca 100644 --- a/zato/lib/common +++ b/zato/lib/common @@ -32,7 +32,7 @@ get_container_name(){ exec_as_zato_in_container() { CONTAINER_NAME=$(get_container_name) local cmd="$1" - if ! docker exec -it "$CONTAINER_NAME" bash -c "su - zato -c '$cmd'"; then + if ! docker exec -i "$CONTAINER_NAME" bash -c "su - zato -c '$cmd'"; then printf "Error: Failed to execute command '%s' as zato user in container '%s'\n" "$cmd" "$CONTAINER_NAME" >&2 return 1 fi diff --git a/zato/resources/opt/zato/restart-load-balancer.sh b/zato/resources/opt/zato/restart-load-balancer.sh new file mode 100755 index 0000000..2b83b64 --- /dev/null +++ b/zato/resources/opt/zato/restart-load-balancer.sh @@ -0,0 +1,14 @@ +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:~/current/bin +export PYTHONPATH=:/opt/zato/current/extlib +export ZATO_PYTHON_REQS=/opt/hot-deploy/python-reqs/requirements.txt +export ZATO_HOT_DEPLOY_DIR=/opt/hot-deploy/services: +export ZATO_USER_CONF_DIR=/opt/hot-deploy/user-conf:/tmp/zato-user-conf +export ZATO_HOT_DEPLOY_PREFER_SNAPSHOTS=True +export Zato_Is_Quickstart= +export Zato_Log_Env_Details=True +export Zato_TLS_Verify= +export Zato_Is_Docker=True + +~/current/bin/zato stop /opt/zato/env/qs-1/load-balancer +kill $(ps -aux | grep zato.agent.load_balancer.main | grep -v grep | grep -v /bin/sh | awk '{ print $2 }') +~/current/bin/zato start /opt/zato/env/qs-1/load-balancer --env-file /opt/hot-deploy/enmasse/env.ini