mirror of https://github.com/OpenVidu/openvidu.git
deployment: Add script to update load balancer IPs in enterprise-ha deployment
parent
b81c0dfccc
commit
c1f3b22bc9
|
@ -298,6 +298,7 @@ usage() {
|
||||||
printf "\n\tstart\t\t\tStart all services"
|
printf "\n\tstart\t\t\tStart all services"
|
||||||
printf "\n\tstop\t\t\tStop all services"
|
printf "\n\tstop\t\t\tStop all services"
|
||||||
printf "\n\trestart\t\t\tRestart all stopped and running services"
|
printf "\n\trestart\t\t\tRestart all stopped and running services"
|
||||||
|
printf "\n\tupdate-loadbalancer\tUpdate load balancer IPs \n\t\t\t\tfrom OPENVIDU_ENTERPRISE_HA_NODE_IPS"
|
||||||
printf "\n\tlogs\t\t\tShow openvidu-server logs"
|
printf "\n\tlogs\t\t\tShow openvidu-server logs"
|
||||||
printf "\n\tupgrade\t\t\tUpgrade to the latest Openvidu version"
|
printf "\n\tupgrade\t\t\tUpgrade to the latest Openvidu version"
|
||||||
printf "\n\tupgrade [version]\tUpgrade to the specific Openvidu version"
|
printf "\n\tupgrade [version]\tUpgrade to the specific Openvidu version"
|
||||||
|
@ -333,6 +334,14 @@ restart)
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
update-loadbalancer)
|
||||||
|
validate_env_vars
|
||||||
|
OPENVIDU_ENTERPRISE_HA_NODE_IPS=$(get_env_var_value "OPENVIDU_ENTERPRISE_HA_NODE_IPS")
|
||||||
|
docker-compose exec -it \
|
||||||
|
-e OPENVIDU_ENTERPRISE_HA_NODE_IPS="${OPENVIDU_ENTERPRISE_HA_NODE_IPS}" \
|
||||||
|
loadbalancer update_enterprise_ha_nodes.sh
|
||||||
|
;;
|
||||||
|
|
||||||
logs)
|
logs)
|
||||||
case "${2-}" in
|
case "${2-}" in
|
||||||
--follow|-f)
|
--follow|-f)
|
||||||
|
|
|
@ -15,7 +15,7 @@ COPY ./default.conf /etc/nginx/conf.d/default.conf
|
||||||
COPY ./default_nginx_conf /default_nginx_conf
|
COPY ./default_nginx_conf /default_nginx_conf
|
||||||
|
|
||||||
# Entrypoint and discover public ip scripts
|
# Entrypoint and discover public ip scripts
|
||||||
COPY ./discover_my_public_ip.sh /usr/local/bin
|
COPY ./discover_my_public_ip.sh ./update_enterprise_ha_nodes.sh /usr/local/bin/
|
||||||
|
|
||||||
# Copy nginx.conf
|
# Copy nginx.conf
|
||||||
COPY ./nginx.conf /etc/nginx/nginx.conf
|
COPY ./nginx.conf /etc/nginx/nginx.conf
|
||||||
|
@ -27,6 +27,7 @@ RUN mkdir -p /var/www/certbot && \
|
||||||
mkdir -p /etc/nginx/vhost.d/ && \
|
mkdir -p /etc/nginx/vhost.d/ && \
|
||||||
mkdir -p /custom-nginx && \
|
mkdir -p /custom-nginx && \
|
||||||
chmod +x /usr/local/bin/entrypoint.sh && \
|
chmod +x /usr/local/bin/entrypoint.sh && \
|
||||||
chmod +x /usr/local/bin/discover_my_public_ip.sh
|
chmod +x /usr/local/bin/discover_my_public_ip.sh && \
|
||||||
|
chmod +x /usr/local/bin/update_enterprise_ha_nodes.sh
|
||||||
|
|
||||||
CMD [ "/usr/local/bin/entrypoint.sh" ]
|
CMD [ "/usr/local/bin/entrypoint.sh" ]
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check if PROXY_MODE is ENTERPRISE_HA
|
||||||
|
if [[ "${PROXY_MODE}" != "ENTERPRISE_HA" ]]; then
|
||||||
|
echo "PROXY_MODE is not ENTERPRISE_HA"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${OPENVIDU_ENTERPRISE_HA_NODE_IPS}" ]]; then
|
||||||
|
echo "OPENVIDU_ENTERPRISE_HA_NODE_IPS is not set."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Updating OPENVIDU_ENTERPRISE_HA_NODE_IPS in load balancer"
|
||||||
|
echo "OPENVIDU_ENTERPRISE_HA_NODE_IPS: ${OPENVIDU_ENTERPRISE_HA_NODE_IPS}"
|
||||||
|
OPENVIDU_ENTERPRISE_HA_NODE_IPS="10.5.0.8,10.5.0.9"
|
||||||
|
IFS=',' read -ra IP_ARRAY <<< "$OPENVIDU_ENTERPRISE_HA_NODE_IPS"
|
||||||
|
NEW_UPSTREAM=""
|
||||||
|
for i in "${IP_ARRAY[@]}"; do
|
||||||
|
NEW_UPSTREAM+=" server ${i}:4443 max_fails=2 fail_timeout=3s;\n"
|
||||||
|
done
|
||||||
|
unset IFS
|
||||||
|
sed -i "/upstream openviduserver {/,/}/c\upstream openviduserver {\n$NEW_UPSTREAM}" /etc/nginx/conf.d/*
|
||||||
|
echo "Updated OPENVIDU_ENTERPRISE_HA_NODE_IPS in load balancer"
|
||||||
|
echo "Reloading nginx"
|
||||||
|
nginx -s reload
|
||||||
|
echo "Nginx updated successfully"
|
||||||
|
fi
|
Loading…
Reference in New Issue