Fixed restart execution in GCP

google-cloud-platform
Piwccle 2025-09-17 11:56:23 +02:00
parent 4cf5c03994
commit 9fd195fde8
1 changed files with 80 additions and 73 deletions

View File

@ -147,6 +147,10 @@ locals {
METADATA_URL="http://metadata.google.internal/computeMetadata/v1"
get_meta() { curl -s -H "Metadata-Flavor: Google" "$${METADATA_URL}/$1"; }
# Create counter file for tracking script executions
touch /tmp/openvidu_install_counter.txt
# Create all the secrets
gcloud secrets create OPENVIDU_URL --replication-policy=automatic || true
gcloud secrets create MEET_INITIAL_ADMIN_USER --replication-policy=automatic || true
@ -627,6 +631,8 @@ locals {
#!/bin/bash -x
set -eu -o pipefail
# Check if installation already completed
if [ ! -f /tmp/openvidu_install_counter.txt ]; then
# install.sh
cat > /usr/local/bin/install.sh << 'INSTALL_EOF'
${local.install_script}
@ -708,9 +714,10 @@ locals {
# Update shared secret
/usr/local/bin/after_install.sh || { echo "[OpenVidu] error updating shared secret"; exit 1; }
else
# Launch on reboot
echo "@reboot /usr/local/bin/restart.sh >> /var/log/openvidu-restart.log" 2>&1 | crontab
/usr/local/bin/restart.sh || { echo "[OpenVidu] error restarting OpenVidu"; exit 1; }
fi
# Wait for the app
/usr/local/bin/check_app_ready.sh