# Alfred Proxy Systemd Service ## Service Management ```bash # Status systemctl --user status alfred-proxy # Start systemctl --user start alfred-proxy # Stop systemctl --user stop alfred-proxy # Restart systemctl --user restart alfred-proxy # Enable (auto-start) systemctl --user enable alfred-proxy # Disable (no auto-start) systemctl --user disable alfred-proxy # View logs journalctl --user -u alfred-proxy -f # View proxy-specific logs tail -f /tmp/alfred-proxy.log ``` ## Auto-Restart The service is configured with: - **Restart=always** - Always restart on failure - **RestartSec=5** - Wait 5 seconds between restarts ## Error Handling Improvements Added to `server.js`: 1. **Global exception handler** - Catches uncaught exceptions 2. **Global rejection handler** - Catches unhandled promise rejections 3. **Proper interval cleanup** - Clears ping intervals on disconnection These prevent the service from crashing on unexpected errors. ## Service File Location `~/.config/systemd/user/alfred-proxy.service` To modify: edit the file, then run: ```bash systemctl --user daemon-reload systemctl --user restart alfred-proxy ```