Skip to content

Commit 1178789

Browse files
rrnewtonclaude
andcommitted
Add --debug flag to happy-launcher.sh for AI auto debugging
- --debug flag enables DANGEROUSLY_LOG_TO_SERVER_FOR_AI_AUTO_DEBUGGING - Server gets the env var directly - Webapp gets PUBLIC_EXPO_DANGEROUSLY_LOG_TO_SERVER_FOR_AI_AUTO_DEBUGGING=1 and EXPO_PUBLIC_DEBUG=1 - Voice session logs now gated by debug flag Usage: ./happy-launcher.sh --debug start 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2410f4b commit 1178789

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

happy

happy-launcher.sh

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,24 @@ CLI_DIR="$SCRIPT_DIR/happy-cli"
3636
WEBAPP_DIR="$SCRIPT_DIR/happy"
3737

3838
# =============================================================================
39-
# Slot Argument Parsing
39+
# Argument Parsing
4040
# =============================================================================
4141

4242
SLOT=""
43+
DEBUG_MODE=""
4344
ARGS=()
4445

45-
# Parse --slot argument before other processing
46+
# Parse --slot and --debug arguments before other processing
4647
while [[ $# -gt 0 ]]; do
4748
case "$1" in
4849
--slot)
4950
SLOT="$2"
5051
shift 2
5152
;;
53+
--debug)
54+
DEBUG_MODE="true"
55+
shift
56+
;;
5257
*)
5358
ARGS+=("$1")
5459
shift
@@ -371,8 +376,16 @@ start_server() {
371376
cp .env.dev .env
372377
fi
373378

379+
# Build environment variables for server
380+
local debug_env=""
381+
if [[ -n "$DEBUG_MODE" ]]; then
382+
debug_env="DANGEROUSLY_LOG_TO_SERVER_FOR_AI_AUTO_DEBUGGING=true"
383+
info "Debug mode enabled for server"
384+
fi
385+
374386
# Start server with environment variables for ports
375387
# DATABASE_URL uses slot-specific database for test isolation
388+
env $debug_env \
376389
PORT="$HAPPY_SERVER_PORT" \
377390
METRICS_PORT="$METRICS_PORT" \
378391
DATABASE_URL="$DATABASE_URL" \
@@ -403,9 +416,18 @@ start_webapp() {
403416
else
404417
info "Starting webapp (slot ${SLOT:-0})..."
405418
cd "$WEBAPP_DIR"
419+
420+
# Build debug environment variables
421+
local debug_env=""
422+
if [[ -n "$DEBUG_MODE" ]]; then
423+
debug_env="PUBLIC_EXPO_DANGEROUSLY_LOG_TO_SERVER_FOR_AI_AUTO_DEBUGGING=1 EXPO_PUBLIC_DEBUG=1"
424+
info "Debug mode enabled for webapp"
425+
fi
426+
406427
# Clear Metro cache to ensure fresh bundle transformation
407428
# The --clear flag is essential for CI environments where the cache may be stale
408-
BROWSER=none \
429+
env $debug_env \
430+
BROWSER=none \
409431
EXPO_PUBLIC_HAPPY_SERVER_URL="$HAPPY_SERVER_URL" \
410432
yarn web --port "$HAPPY_WEBAPP_PORT" --clear > "$LOG_DIR/webapp.log" 2>&1 &
411433
echo $! > "$PIDS_DIR/webapp.pid"
@@ -979,7 +1001,11 @@ case "${1:-}" in
9791001
echo ""
9801002
echo "Happy Self-Hosted Service Launcher"
9811003
echo ""
982-
echo "Usage: $0 [--slot N] <command> [options]"
1004+
echo "Usage: $0 [--slot N] [--debug] <command> [options]"
1005+
echo ""
1006+
echo "Options:"
1007+
echo " --slot N Use slot N for port/database isolation (default: 0)"
1008+
echo " --debug Enable debug logging (DANGEROUSLY_LOG_TO_SERVER_FOR_AI_AUTO_DEBUGGING)"
9831009
echo ""
9841010
echo "Slot Concept:"
9851011
echo " --slot 0 (default) Primary instance: Server=3005, Webapp=8081, DB=handy"

0 commit comments

Comments
 (0)