@@ -14,6 +14,7 @@ TERRAFORM_DIR="${PROJECT_ROOT}/infrastructure/terraform"
14
14
ENVIRONMENT=" ${1:- local} "
15
15
VM_IP=" ${2:- } "
16
16
SKIP_HEALTH_CHECK=" ${SKIP_HEALTH_CHECK:- false} "
17
+ SKIP_WAIT=" ${SKIP_WAIT:- false} " # New parameter for skipping waiting
17
18
ENABLE_HTTPS=" ${ENABLE_SSL:- true} " # Enable HTTPS with self-signed certificates by default
18
19
19
20
# Source shared shell utilities
@@ -707,23 +708,27 @@ wait_for_services() {
707
708
setup_backup_automation () {
708
709
local vm_ip=" $1 "
709
710
711
+ log_info " Checking backup automation configuration..."
712
+
710
713
# Load environment variables from the generated .env file
711
714
if [[ -f " ${PROJECT_ROOT} /application/storage/compose/.env" ]]; then
712
715
# shellcheck source=/dev/null
713
716
source " ${PROJECT_ROOT} /application/storage/compose/.env"
717
+ log_info " ✅ Loaded environment configuration"
714
718
else
715
- log_warning " Environment file not found, using defaults"
719
+ log_warning " ⚠️ Environment file not found, using defaults"
716
720
fi
717
721
718
722
# Check if backup automation is enabled
719
723
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} )"
721
725
return 0
722
726
fi
723
727
724
- log_info " Setting up automated database backups ..."
728
+ log_info " ✅ Database backup automation enabled - proceeding with setup ..."
725
729
726
730
# Create backup directory and set permissions
731
+ log_info " ⏳ Creating backup directory and setting permissions..."
727
732
vm_exec " ${vm_ip} " "
728
733
# Create backup directory if it doesn't exist
729
734
sudo mkdir -p /var/lib/torrust/mysql/backups
@@ -734,8 +739,10 @@ setup_backup_automation() {
734
739
# Set appropriate permissions
735
740
chmod 755 /var/lib/torrust/mysql/backups
736
741
" " Setting up backup directory"
742
+ log_info " ✅ Backup directory setup completed"
737
743
738
744
# Install crontab entry for automated backups
745
+ log_info " ⏳ Installing MySQL backup cron job..."
739
746
vm_exec " ${vm_ip} " "
740
747
cd /home/torrust/github/torrust/torrust-tracker-demo
741
748
@@ -752,8 +759,10 @@ setup_backup_automation() {
752
759
echo 'Current crontab entries:'
753
760
crontab -l || echo 'No crontab entries found'
754
761
" " Installing MySQL backup cron job"
762
+ log_info " ✅ Cron job installation completed"
755
763
756
764
# Test backup script functionality
765
+ log_info " ⏳ Validating backup script functionality..."
757
766
vm_exec " ${vm_ip} " "
758
767
cd /home/torrust/github/torrust/torrust-tracker-demo/application
759
768
@@ -775,8 +784,9 @@ setup_backup_automation() {
775
784
echo '✅ Fixed backup script permissions'
776
785
fi
777
786
" " Validating backup script"
787
+ log_info " ✅ Backup script validation completed"
778
788
779
- log_success " Database backup automation configured successfully"
789
+ log_success " 🎉 Database backup automation configured successfully"
780
790
log_info " Backup schedule: Daily at 3:00 AM"
781
791
log_info " Backup location: /var/lib/torrust/mysql/backups"
782
792
log_info " Retention period: ${BACKUP_RETENTION_DAYS:- 7} days"
@@ -817,19 +827,32 @@ run_stage() {
817
827
docker compose --env-file /var/lib/torrust/compose/.env up -d
818
828
" " Starting application services"
819
829
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
822
840
823
841
# Setup HTTPS with self-signed certificates (if enabled)
824
842
if [[ " ${ENABLE_HTTPS} " == " true" ]]; then
843
+ log_info " ⏳ Setting up HTTPS certificates..."
825
844
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} )"
827
848
fi
828
849
829
850
# Setup database backup automation (if enabled)
851
+ log_info " ⏳ Setting up database backup automation..."
830
852
setup_backup_automation " ${vm_ip} "
853
+ log_success " ✅ Database backup automation completed"
831
854
832
- log_success " Run stage completed"
855
+ log_success " 🎉 Run stage completed successfully "
833
856
}
834
857
835
858
# Validate deployment (Health checks)
@@ -1018,10 +1041,14 @@ main() {
1018
1041
test_ssh_connection " ${vm_ip} "
1019
1042
wait_for_system_ready " ${vm_ip} "
1020
1043
release_stage " ${vm_ip} "
1021
- run_stage " ${vm_ip} "
1044
+ run_stage " ${vm_ip} " # This already includes waiting for services
1022
1045
1023
1046
if [[ " ${SKIP_HEALTH_CHECK} " != " true" ]]; then
1047
+ log_info " ⏳ Running deployment validation..."
1024
1048
validate_deployment " ${vm_ip} "
1049
+ log_success " ✅ Deployment validation completed"
1050
+ else
1051
+ log_warning " ⚠️ Skipping deployment validation (SKIP_HEALTH_CHECK=true)"
1025
1052
fi
1026
1053
1027
1054
show_connection_info " ${vm_ip} "
@@ -1040,6 +1067,7 @@ Arguments:
1040
1067
1041
1068
Environment Variables:
1042
1069
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)
1043
1071
1044
1072
Examples:
1045
1073
$0 local # Deploy to local environment (get IP from Terraform)
0 commit comments