## Systemd Service Lifecycle Errors

Common systemd pattern mismatches and how to resolve them:

### 1. Service Activation Problems
Wrong:
```ini
ExecStart=/usr/local/bin/llama-server -m /models/Qwen3-35B.gguf --port 8081
```
Fixed:
```ini
[Service]
User=rurouni
WorkingDirectory=/home/rurouni
ExecStart=/usr/local/bin/llama-server \
  -m /models/llm/daily/Qwen3.6-35B-A3B-UD-Q4_K_S.gguf \
  --port 8081 \
  --host 0.0.0.0 \
  --cache-type-k turbo4 \
  --cache-type-v turbo4 \
  -ctk turbo4 \
  -ctv turbo4 \
  -ngl 99 \
  --mlock \
  --prio 2 \
  --ctx-size 128000
```
- Added WorkingDirectory for relative path consistency
- Split ExecStart arguments for readability
- Fixed parameter order to match model requirements

### 2. Service File Missing
Wrong:
```
Unit file not found: %s - %s
```
Fixed with:
```bash
# Create service and reload daemon
cat > /etc/systemd/system/llama-server.service << 'EOL'
[Service]
User=rurouni
WorkingDirectory=/home/rurouni
ExecStart=
[Install]
WantedBy=multi-user.target
EOL
sudo systemctl daemon-reload
```
- Used heredoc syntax for clean service file creation
- Included proper install section for persistent enablement

### 3. Service Start Failures
Common failure:
```
Failed to determine service path
```
Fixed by:
- Making all paths absolute
- Adding `--host 0.0.0.0` for external access
- Ensuring models have proper paths in ExecStart
- Adding `WantedBy=multi-user.target` for boot enablement

## Verification Tools
```bash
# Complete service validation
sudo systemctl daemon-reload
sudo systemctl enable llama-server
sudo systemctl start llama-server
sudo systemctl status llama-server --no-pager
```
```bash
# Error trace capture
journalctl -u llama-server.service -f
```