#!/bin/bash

# Set the parent directory
parentDir="/c/xampp/htdocs/eGovApp"

# Change the working directory to the dua.backend directory
cd "$parentDir/dua.backend"

# Start the dua.backend project in the background
php artisan bff:work &

# Loop through the other Laravel project directories and start the RabbitMQ reader in the background
laravelDirs=("ms.riview" "ms.dpass" "ms.rescom" "ms.papyros" "ms.support" "ms.contacts" "ms.notifications")
for dir in "${laravelDirs[@]}"; do
    # Change the working directory to the current Laravel project directory
    cd "$parentDir/$dir"
    
    # Start the RabbitMQ reader in the background
    php artisan rabbitmq:read &
done

# Change the working directory to the ms.contacts directory
cd "$parentDir/ms.contacts"

# Start the mail queue in the background for ms.contacts
php artisan mail:work &

# Change the working directory to the ms.notifications directory
cd "$parentDir/ms.notifications"

# Start the mail queue in the background for ms.notifications
php artisan notification:work &

# Return to the original directory (optional)
cd "$parentDir"
