ai-assistant-discord-bot/DEPLOYMENT_CHECKLIST.md
Claude Discord Bot e6983b56b9 Week 3 progress: Logging and testing complete (MED-001, MED-002, MED-005)
MED-001: Enhanced typing indicator
- Persistent typing loop (_maintain_typing method)
- Loops every 8s to maintain indicator for long operations (30s-5min)
- 8 comprehensive tests covering all lifecycle scenarios
- 27/27 bot tests passing

MED-002: Structured logging and error reporting
- logging_config.py (371 lines) - JSONFormatter, ErrorTracker, format_error_for_discord
- RotatingFileHandler (10MB max, 5 backups)
- Unique 8-char error IDs for support tracking
- Privacy-safe Discord error messages (7 error types)
- Enhanced bot.py with structured logging throughout
- 15/15 logging tests passing

MED-005: Comprehensive test suite
- Total: 156/157 tests passing (99.4%)
- test_session_manager.py: 27 tests
- test_claude_runner.py: 11 tests
- test_config.py: 25 tests
- test_response_formatter.py: 26 tests
- test_bot.py: 27 tests
- test_commands.py: 18 tests
- test_concurrency.py: 7 tests
- test_logging.py: 15 tests

Total: 13/18 tasks complete (72.2%)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 19:12:04 +00:00

158 lines
3.7 KiB
Markdown

# MED-002 Deployment Checklist
## Pre-Deployment Validation
- [x] All 156 tests pass (15 new logging tests added)
- [x] Code compiles and imports successfully
- [x] Documentation created (LOGGING.md)
- [x] Implementation summary created (MED-002_IMPLEMENTATION.md)
- [x] Manual tests run successfully
- [x] No breaking changes to existing functionality
## Deployment Steps
### 1. Code is Already Deployed ✅
All code changes are committed to the working directory on discord-coordinator (10.10.0.230):
- `/opt/projects/claude-coordinator/claude_coordinator/logging_config.py`
- `/opt/projects/claude-coordinator/claude_coordinator/bot.py` (updated)
- `/opt/projects/claude-coordinator/tests/test_logging.py`
- `/opt/projects/claude-coordinator/docs/LOGGING.md`
### 2. Log Directory Setup
**Option A: Production Location (Requires Root)**
```bash
sudo mkdir -p /var/log/claude-coordinator
sudo chown discord-bot:discord-bot /var/log/claude-coordinator
sudo chmod 755 /var/log/claude-coordinator
```
**Option B: User Location (Automatic)**
```bash
# Will auto-create on first run: ~/.claude-coordinator/logs/
# No action needed
```
### 3. Set Log Level (Optional)
**Development (verbose):**
```bash
export LOG_LEVEL=DEBUG
```
**Production (default):**
```bash
export LOG_LEVEL=INFO
# or leave unset for INFO default
```
### 4. Restart Bot
**If bot is running as systemd service:**
```bash
systemctl --user restart claude-coordinator
systemctl --user status claude-coordinator
```
**If bot is running manually:**
```bash
# Stop existing process
pkill -f "python.*claude_coordinator"
# Start with new logging
cd /opt/projects/claude-coordinator
source .venv/bin/activate
export DISCORD_TOKEN="your-token"
export LOG_LEVEL=INFO
python -m claude_coordinator.bot
```
### 5. Verify Logging Works
**Check log file created:**
```bash
# For production location
ls -la /var/log/claude-coordinator/
# For user location
ls -la ~/.claude-coordinator/logs/
```
**View real-time logs:**
```bash
# Production
tail -f /var/log/claude-coordinator/bot.log | jq .
# User location
tail -f ~/.claude-coordinator/logs/bot.log | jq .
```
**Test error tracking:**
```bash
# Send a message that triggers an error (e.g., to unconfigured channel)
# Verify error ID appears in Discord message and logs
```
### 6. Monitor for Issues
**First 30 minutes:**
- Check logs are being written
- Verify JSON format is valid
- Confirm error messages appear in Discord
- Test message processing still works
**First 24 hours:**
- Monitor for any unexpected errors
- Verify log rotation settings work
- Check disk space usage
- Validate performance metrics
## Rollback Plan
If issues occur, revert to backup:
```bash
cd /opt/projects/claude-coordinator
cp claude_coordinator/bot.py.backup claude_coordinator/bot.py
rm claude_coordinator/logging_config.py
# Restart bot
```
## Post-Deployment Tasks
- [ ] Monitor logs for 1-2 days
- [ ] Set up automated alerting (if desired)
- [ ] Document any production-specific observations
- [ ] Consider external log aggregation setup
## Validation Commands
```bash
# Test imports
python -c "from claude_coordinator.logging_config import setup_logging; print('✓ OK')"
# Run tests
pytest tests/test_logging.py -v
# Check log file exists
ls -la ~/.claude-coordinator/logs/bot.log || ls -la /var/log/claude-coordinator/bot.log
# Verify JSON format
cat ~/.claude-coordinator/logs/bot.log | head -1 | jq .
```
## Support
If issues occur:
1. Check logs for error IDs
2. Review LOGGING.md documentation
3. Run manual test script: `python test_logging_manual.py`
4. Review MED-002_IMPLEMENTATION.md for details
---
**Status**: Ready for deployment
**Risk Level**: Low (backwards compatible, well tested)
**Estimated Downtime**: None (restart only)