#!/usr/bin/env bash

# Number of queue workers to run
NUM_WORKERS=20

# Loop to start the specified number of queue workers
for ((i=1; i<=NUM_WORKERS; i++))
do
    echo "Starting queue worker $i"
    drush queue:work &
done

# Set up trap to handle Ctrl-C (SIGINT) and SIGTERM
trap 'kill $(jobs -p) 2>/dev/null; exit' INT TERM SIGTERM SIGINT

# Wait for all background processes to finish
wait
