Add UV run support and systemd service installer

**UV Integration:**
- Updated pyproject.toml with [tool.uv.scripts]
- Added 'uv run start' to launch wedding phone
- Added 'uv run test' to run audio tests
- Refactored main code into main() function
- Added proper entry point for package installation

**Systemd Service:**
- Created wedding-phone.service template
- Service runs with UV for dependency management
- Automatic restart on failure
- Proper security hardening (NoNewPrivileges, PrivateTmp)
- GPIO and audio group access configured

**Service Installer:**
- Created install_service.sh automated installer
- Auto-detects project path and user
- Checks for UV installation and dependencies
- Configures service file with correct paths
- Option to enable and start immediately
- Provides helpful command reference

**Installer Features:**
- Validates config.json exists (creates from example if missing)
- Installs UV dependencies automatically
- Updates service file paths dynamically
- Color-coded output for clarity
- Error checking at each step
- Clean installation process

**Usage:**
```bash
# Run directly with UV
uv run start

# Install as system service
./install_service.sh

# Service management
sudo systemctl start wedding-phone
sudo systemctl stop wedding-phone
sudo journalctl -u wedding-phone -f
```

**Documentation:**
- Updated README with UV commands
- Added service installation guide
- Removed old manual systemd instructions
- Added service management commands
- Updated file structure documentation

**Benefits:**
- Easier to run (single command)
- Automatic startup on boot
- Better dependency management
- Professional service integration
- Simplified installation process

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-24 16:52:08 +07:00
parent d07cb82772
commit 81731ce4a4
5 changed files with 219 additions and 38 deletions

View File

@@ -11,6 +11,10 @@ dependencies = [
"RPi.GPIO>=0.7.1",
]
[project.scripts]
wedding-phone = "rotary_phone_web:main"
wedding-phone-test = "test_complete:main"
[project.optional-dependencies]
dev = [
"pytest>=7.0.0",
@@ -22,3 +26,7 @@ build-backend = "hatchling.build"
[tool.uv]
dev-dependencies = []
[tool.uv.scripts]
start = "python rotary_phone_web.py"
test = "python test_complete.py"