| # Start all four workers locally with optional per-worker debugpy support. | |
| # | |
| # Usage: | |
| # ./run_workers_dev.sh # all workers, no debugger | |
| # DEBUG_WORKER=allocation ./run_workers_dev.sh # allocation worker opens :5678 | |
| # DEBUG_WORKER=scheduler ./run_workers_dev.sh # scheduler worker opens :5679 | |
| # DEBUG_WORKER=expiry ./run_workers_dev.sh # expiry worker opens :5680 | |
| # DEBUG_WORKER=response ./run_workers_dev.sh # response worker opens :5681 | |
| # | |
| # Set DEBUGPY_WAIT=1 alongside DEBUG_WORKER to block until debugger attaches. | |
| set -e | |
| LOG_DIR="logs" | |
| mkdir -p "$LOG_DIR" | |
| export DEBUG_WORKER="${DEBUG_WORKER:-}" | |
| export DEBUGPY_WAIT="${DEBUGPY_WAIT:-0}" | |
| echo "Starting workers (DEBUG_WORKER=${DEBUG_WORKER:-none})..." | |
| python3 -m app.workers.run_scheduler_worker > "$LOG_DIR/scheduler.log" 2>&1 & | |
| PIDS=($!) | |
| python3 -m app.workers.run_allocation_worker > "$LOG_DIR/allocation.log" 2>&1 & | |
| PIDS+=($!) | |
| python3 -m app.workers.run_expiry_worker > "$LOG_DIR/expiry.log" 2>&1 & | |
| PIDS+=($!) | |
| python3 -m app.workers.run_response_worker > "$LOG_DIR/response.log" 2>&1 & | |
| PIDS+=($!) | |
| echo "Workers running — PIDs: ${PIDS[*]}" | |
| echo "Logs: $LOG_DIR/{scheduler,allocation,expiry,response}.log" | |
| echo "Press Ctrl+C to stop all." | |
| cleanup() { | |
| echo "" | |
| echo "Stopping workers..." | |
| kill "${PIDS[@]}" 2>/dev/null | |
| wait "${PIDS[@]}" 2>/dev/null | |
| echo "Done." | |
| exit 0 | |
| } | |
| trap cleanup INT TERM | |
| tail -f \ | |
| "$LOG_DIR/scheduler.log" \ | |
| "$LOG_DIR/allocation.log" \ | |
| "$LOG_DIR/expiry.log" \ | |
| "$LOG_DIR/response.log" | |