#!/bin/bash
cd /Users/ashwin/workspace/nxtgauge-backend-rust
set -a && source .env && set +a

echo "Starting companies on port 9102..."
PORT=9102 RUST_LOG=info ./target/release/companies &>/dev/null &
echo "Started companies (PID: $!)"

echo "Starting customers on port 9105..."
PORT=9105 RUST_LOG=info ./target/release/customers &>/dev/null &
echo "Started customers (PID: $!)"

echo "Starting employees on port 9106..."
PORT=9106 RUST_LOG=info ./target/release/employees &>/dev/null &
echo "Started employees (PID: $!)"

echo "Starting cron..."
RUST_LOG=info ./target/release/cron &>/dev/null &
echo "Started cron (PID: $!)"

sleep 3

echo ""
echo "=== Service Status ==="
lsof -i :9100 -i :9101 -i :9102 -i :9104 -i :9105 -i :9106 2>/dev/null | grep LISTEN | grep -v grep
echo ""
echo "=== Running Rust processes ==="
ps aux | grep -E "target/release/(companies|customers|employees|cron)" | grep -v grep
