@@ -14,6 +14,7 @@ TERRAFORM_DIR="${PROJECT_ROOT}/infrastructure/terraform"
1414ENVIRONMENT=" ${1:- local} "
1515VM_IP=" ${2:- } "
1616SKIP_HEALTH_CHECK=" ${SKIP_HEALTH_CHECK:- false} "
17+ SKIP_WAIT=" ${SKIP_WAIT:- false} " # New parameter for skipping waiting
1718ENABLE_HTTPS=" ${ENABLE_SSL:- true} " # Enable HTTPS with self-signed certificates by default
1819
1920# Source shared shell utilities
@@ -707,23 +708,27 @@ wait_for_services() {
707708setup_backup_automation () {
708709 local vm_ip=" $1 "
709710
711+ log_info " Checking backup automation configuration..."
712+
710713 # Load environment variables from the generated .env file
711714 if [[ -f " ${PROJECT_ROOT} /application/storage/compose/.env" ]]; then
712715 # shellcheck source=/dev/null
713716 source " ${PROJECT_ROOT} /application/storage/compose/.env"
717+ log_info " ✅ Loaded environment configuration"
714718 else
715- log_warning " Environment file not found, using defaults"
719+ log_warning " ⚠️ Environment file not found, using defaults"
716720 fi
717721
718722 # Check if backup automation is enabled
719723 if [[ " ${ENABLE_DB_BACKUPS:- false} " != " true" ]]; then
720- log_info " Database backup automation disabled (ENABLE_DB_BACKUPS=false)"
724+ log_info " ⏹️ Database backup automation disabled (ENABLE_DB_BACKUPS=${ENABLE_DB_BACKUPS :- false} )"
721725 return 0
722726 fi
723727
724- log_info " Setting up automated database backups ..."
728+ log_info " ✅ Database backup automation enabled - proceeding with setup ..."
725729
726730 # Create backup directory and set permissions
731+ log_info " ⏳ Creating backup directory and setting permissions..."
727732 vm_exec " ${vm_ip} " "
728733 # Create backup directory if it doesn't exist
729734 sudo mkdir -p /var/lib/torrust/mysql/backups
@@ -734,8 +739,10 @@ setup_backup_automation() {
734739 # Set appropriate permissions
735740 chmod 755 /var/lib/torrust/mysql/backups
736741 " " Setting up backup directory"
742+ log_info " ✅ Backup directory setup completed"
737743
738744 # Install crontab entry for automated backups
745+ log_info " ⏳ Installing MySQL backup cron job..."
739746 vm_exec " ${vm_ip} " "
740747 cd /home/torrust/github/torrust/torrust-tracker-demo
741748
@@ -752,8 +759,10 @@ setup_backup_automation() {
752759 echo 'Current crontab entries:'
753760 crontab -l || echo 'No crontab entries found'
754761 " " Installing MySQL backup cron job"
762+ log_info " ✅ Cron job installation completed"
755763
756764 # Test backup script functionality
765+ log_info " ⏳ Validating backup script functionality..."
757766 vm_exec " ${vm_ip} " "
758767 cd /home/torrust/github/torrust/torrust-tracker-demo/application
759768
@@ -775,8 +784,9 @@ setup_backup_automation() {
775784 echo '✅ Fixed backup script permissions'
776785 fi
777786 " " Validating backup script"
787+ log_info " ✅ Backup script validation completed"
778788
779- log_success " Database backup automation configured successfully"
789+ log_success " 🎉 Database backup automation configured successfully"
780790 log_info " Backup schedule: Daily at 3:00 AM"
781791 log_info " Backup location: /var/lib/torrust/mysql/backups"
782792 log_info " Retention period: ${BACKUP_RETENTION_DAYS:- 7} days"
@@ -817,19 +827,32 @@ run_stage() {
817827 docker compose --env-file /var/lib/torrust/compose/.env up -d
818828 " " Starting application services"
819829
820- # Wait for services to initialize
821- wait_for_services " ${vm_ip} "
830+ # Wait for services to initialize (unless skipped)
831+ if [[ " ${SKIP_WAIT} " != " true" ]]; then
832+ log_info " ⏳ Waiting for application services to be healthy..."
833+ log_info " (Use SKIP_WAIT=true to skip this waiting)"
834+ wait_for_services " ${vm_ip} "
835+ log_success " 🎉 All application services are healthy and ready!"
836+ else
837+ log_warning " ⚠️ Skipping wait for service health checks (SKIP_WAIT=true)"
838+ log_info " Note: Services may not be ready immediately"
839+ fi
822840
823841 # Setup HTTPS with self-signed certificates (if enabled)
824842 if [[ " ${ENABLE_HTTPS} " == " true" ]]; then
843+ log_info " ⏳ Setting up HTTPS certificates..."
825844 log_info " HTTPS certificates already generated - services should be running with HTTPS..."
826- log_success " HTTPS setup completed"
845+ log_success " ✅ HTTPS setup completed"
846+ else
847+ log_info " ⏹️ HTTPS setup skipped (ENABLE_HTTPS=${ENABLE_HTTPS} )"
827848 fi
828849
829850 # Setup database backup automation (if enabled)
851+ log_info " ⏳ Setting up database backup automation..."
830852 setup_backup_automation " ${vm_ip} "
853+ log_success " ✅ Database backup automation completed"
831854
832- log_success " Run stage completed"
855+ log_success " 🎉 Run stage completed successfully "
833856}
834857
835858# Validate deployment (Health checks)
@@ -1018,10 +1041,14 @@ main() {
10181041 test_ssh_connection " ${vm_ip} "
10191042 wait_for_system_ready " ${vm_ip} "
10201043 release_stage " ${vm_ip} "
1021- run_stage " ${vm_ip} "
1044+ run_stage " ${vm_ip} " # This already includes waiting for services
10221045
10231046 if [[ " ${SKIP_HEALTH_CHECK} " != " true" ]]; then
1047+ log_info " ⏳ Running deployment validation..."
10241048 validate_deployment " ${vm_ip} "
1049+ log_success " ✅ Deployment validation completed"
1050+ else
1051+ log_warning " ⚠️ Skipping deployment validation (SKIP_HEALTH_CHECK=true)"
10251052 fi
10261053
10271054 show_connection_info " ${vm_ip} "
@@ -1040,6 +1067,7 @@ Arguments:
10401067
10411068Environment Variables:
10421069 SKIP_HEALTH_CHECK Skip health check validation (true/false, default: false)
1070+ SKIP_WAIT Skip waiting for services to be ready (true/false, default: false)
10431071
10441072Examples:
10451073 $0 local # Deploy to local environment (get IP from Terraform)
0 commit comments