#!/bin/bash # Test script to verify daemon shutdown behavior echo "๐Ÿงช Testing daemon shutdown behavior..." # Start daemon in background and capture its PID echo "๐Ÿš€ Starting daemon..." cd "$(dirname "$0")" cargo run & DAEMON_PID=$! echo "๐Ÿ“Š Daemon PID: $DAEMON_PID" # Wait a moment for daemon to start sleep 2 # Send a test notification echo "๐Ÿ“ก Sending test notification..." ../ac-notify success "test" # Wait a moment sleep 1 # Check if daemon is running if ps -p $DAEMON_PID > /dev/null; then echo "โœ… Daemon is running (PID $DAEMON_PID)" else echo "โŒ Daemon is not running" exit 1 fi # Test signal handling echo "๐Ÿ“ค Sending SIGTERM to daemon..." kill -TERM $DAEMON_PID # Wait a moment for graceful shutdown sleep 2 # Check if daemon stopped if ps -p $DAEMON_PID > /dev/null; then echo "โŒ Daemon still running after SIGTERM" kill -9 $DAEMON_PID # Force kill exit 1 else echo "โœ… Daemon stopped gracefully after SIGTERM" fi echo "๐ŸŽ‰ All tests passed!"