#!/bin/bash RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' MAGENTA='\033[0;35m' CYAN='\033[0;36m' NC='\033[0m' cleanup() { echo -e "\n${YELLOW}Shutting down all services...${NC}" kill $(jobs -p) 2>/dev/null wait echo -e "${GREEN}All services stopped${NC}" exit 0 } trap cleanup EXIT INT TERM run_service() { local name=$1 local color=$2 local dir=$3 shift 3 local cmd="$@" echo -e "${color}Starting $name...${NC}" (cd "$dir" && exec $cmd 2>&1 | sed "s/^/[$name] /" | while IFS= read -r line; do echo -e "${color}${line}${NC}"; done) & } echo -e "${CYAN}Checking requirements...${NC}" if ! command -v air &> /dev/null; then echo -e "${RED}Error: 'air' is not installed" exit 1 fi if ! command -v pnpm &> /dev/null; then echo -e "${RED}Error: 'pnpm' is not installed}" exit 1 fi if ! command -v deno &> /dev/null; then echo -e "${RED}Error: 'deno' is not installed" exit 1 fi echo -e "${GREEN}All requirements satisfied${NC}\n" echo -e "${CYAN}Starting all development servers...${NC}\n" run_service "Backend" "$GREEN" "hiling_go" air run_service "Meilisearch" "$YELLOW" "hiling_go" ./dev-meilisearch.sh run_service "Frontend" "$BLUE" "hilingriviw" pnpm dev --host run_service "OpenGraph" "$MAGENTA" "hiling-opengraph" deno task dev echo -e "\n${CYAN}All services started!${NC}" echo -e "${CYAN}Press Ctrl+C to stop all services${NC}\n" wait