#!/usr/bin/env bash # Simplified development server for HdM slides # Starts single Marp server for all courses set -e # Configuration SLIDES_DIR="slides" DEV_PORT=3000 # Colors GREEN='\033[0;32m' BLUE='\033[0;34m' RED='\033[0;31m' NC='\033[0m' # No Color # Cleanup function cleanup() { echo -e "\n${RED}Shutting down dev server...${NC}" pkill -f "marp-cli.*--server" 2>/dev/null || true exit 0 } # Kill existing processes on our port kill_existing() { echo -e "${BLUE}Cleaning up existing processes...${NC}" pkill -9 -f "marp-cli" 2>/dev/null || true fuser -k $DEV_PORT/tcp 2>/dev/null || true sleep 1 } # Main trap cleanup SIGINT SIGTERM kill_existing echo -e "${GREEN}Starting development server...${NC}" echo "" echo -e " Server: ${BLUE}http://localhost:$DEV_PORT${NC}" echo -e " Slides: ${BLUE}$SLIDES_DIR/${NC}" echo "" echo -e "Available courses:" echo -e " 223015b: ${BLUE}http://localhost:$DEV_PORT/223015b/${NC}" echo -e " 223015c: ${BLUE}http://localhost:$DEV_PORT/223015c/${NC}" echo "" echo -e "Press ${RED}Ctrl+C${NC} to stop the server" echo "" # Start single Marp server for all slides PORT=$DEV_PORT npx @marp-team/marp-cli --server "$SLIDES_DIR/" # Wait for process to exit wait