Service Management
Complete guide for managing Chatty AI services in day-to-day operations.
Starting Services
Portainer Deployment
Services are managed through Portainer UI:
- Log in to Portainer Server
- Navigate to Stacks
- Select chatty-app stack
- Click Start or Restart
Vendor typically manages - customer should not need to start/stop services.
Docker Compose Deployment
Start all services:
cd /path/to/chatty-app/deploy
docker compose up -d
Start specific service:
docker compose up -d chattyai
docker compose up -d nginx
docker compose up -d db
Stopping Services
Graceful Shutdown
Stop all services gracefully:
docker compose down
Stop specific service:
docker compose stop chattyai
docker compose stop nginx
Force Stop
If services don't stop gracefully:
docker compose kill
Restarting Services
Restart All Services
docker compose restart
Restart Specific Service
# Restart main application
docker compose restart chattyai
# Restart nginx
docker compose restart nginx
# Restart database
docker compose restart db
# Restart Qdrant
docker compose restart qdrant
When to Restart
Restart services after:
- Configuration changes
- Environment variable updates
- Certificate updates
- Performance issues
- Memory leaks
Checking Service Status
View Running Containers
docker ps
Expected output: All 11 containers running
Check Specific Service
docker ps | grep chattyai
docker ps | grep nginx
docker ps | grep db
Container Health
# Detailed status
docker inspect chattyai | grep -A 10 State
# Health check status
docker inspect chattyai | grep Health
Viewing Logs
Real-time Logs
# All services
docker compose logs -f
# Specific service
docker compose logs -f chattyai
docker compose logs -f nginx
docker compose logs -f db
Recent Logs
# Last 100 lines
docker compose logs --tail=100 chattyai
# Last 10 minutes
docker compose logs --since=10m chattyai
Save Logs to File
docker compose logs chattyai > chattyai.log
docker compose logs nginx > nginx.log
Resource Monitoring
Container Resource Usage
# Real-time stats
docker stats
# Single snapshot
docker stats --no-stream
# Specific container
docker stats chattyai
Monitor:
- CPU usage
- Memory usage
- Network I/O
- Disk I/O
System Resources
# CPU and memory
htop
# Disk usage
df -h
# Disk I/O
iostat -x 1
# Network
iftop
Container Management
Execute Commands in Container
# Open shell
docker exec -it chattyai bash
# Run single command
docker exec chattyai ls -la /app
# Check database
docker exec db psql -U chattyAdmin -d chattydb -c "SELECT version();"
Copy Files
# Copy from container
docker cp chattyai:/app/data/file.txt ./file.txt
# Copy to container
docker cp ./config.yaml chattyai:/app/config.yaml
Inspect Container
# Full details
docker inspect chattyai
# Specific field
docker inspect chattyai | grep IPAddress
docker inspect chattyai | grep Mounts
Volume Management
List Volumes
docker volume ls | grep chatty
Expected volumes:
- chatty-app_db_data
- chatty-app_qdrant
- chatty-app_chattyai
- chatty-app_pipelines
- chatty-app_n8n_data
- chatty-app_chattydatabases_data
Inspect Volume
docker volume inspect chatty-app_db_data
Volume Usage
# Check volume sizes
docker system df -v
Network Management
List Networks
docker network ls | grep chatty
Inspect Network
docker network inspect chatty-app_default
Test Connectivity
# From chattyai to db
docker exec chattyai nc -zv db 5432
# From chattyai to qdrant
docker exec chattyai nc -zv qdrant 6333
Updating Services
Pull New Images
# Pull all images
docker compose pull
# Pull specific image
docker compose pull chattyai
Update and Restart
# Pull and restart
docker compose pull
docker compose up -d
# Specific service
docker compose pull chattyai
docker compose up -d chattyai
See Upgrades for detailed upgrade procedures.
Cleaning Up
Remove Stopped Containers
docker compose down
Remove Unused Images
# Remove dangling images
docker image prune
# Remove all unused images
docker image prune -a
Remove Unused Volumes
⚠️ WARNING: This will delete data!
# Remove unused volumes (DANGEROUS)
docker volume prune
# Remove specific volume
docker volume rm chatty-app_old_volume
Clean System
# Remove all unused resources
docker system prune
# Include volumes (DANGEROUS)
docker system prune --volumes
Common Operations
Restart After Config Change
# 1. Stop services
docker compose down
# 2. Update .env file
nano .env
# 3. Start services
docker compose up -d
# 4. Verify
docker compose logs -f chattyai
Restart After Certificate Update
# 1. Update certificates
cp new-cert.pem /path/to/certs/chattyai/fullchain.pem
cp new-key.pem /path/to/certs/chattyai/privkey.pem
# 2. Restart nginx only
docker compose restart nginx
# 3. Verify
curl -vI https://YOUR_DOMAIN
Clear Application Cache
# Restart main application
docker compose restart chattyai
# Or recreate container
docker compose up -d --force-recreate chattyai
Troubleshooting
Container Won't Start
# Check logs
docker compose logs chattyai
# Check for port conflicts
netstat -tulpn | grep LISTEN
# Check resource availability
free -h
df -h
Container Keeps Restarting
# Check restart count
docker ps -a | grep chattyai
# View logs
docker compose logs --tail=200 chattyai
# Check health
docker inspect chattyai | grep -A 20 State
High Resource Usage
# Identify resource hog
docker stats --no-stream
# Check container logs
docker compose logs --tail=100 chattyai
# Restart service
docker compose restart chattyai
Database Connection Issues
# Check database is running
docker ps | grep db
# Check database logs
docker compose logs db
# Test connection
docker exec chattyai nc -zv db 5432
# Verify credentials
docker exec db psql -U chattyAdmin -d chattydb -c "SELECT 1;"
Maintenance Windows
Planned Maintenance
- Notify users of maintenance window
- Backup data before changes
- Stop services gracefully
- Perform maintenance
- Start services
- Validate deployment
- Monitor for issues
Emergency Maintenance
- Assess situation
- Quick backup if possible
- Stop affected services
- Fix issue
- Restart services
- Validate and monitor
Automation
Systemd Service (Optional)
Create /etc/systemd/system/chatty-app.service:
[Unit]
Description=Chatty AI Application
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/path/to/chatty-app/deploy
ExecStart=/usr/bin/docker compose up -d
ExecStop=/usr/bin/docker compose down
TimeoutStartSec=0
[Install]
WantedBy=multi-user.target
Enable and start:
sudo systemctl enable chatty-app
sudo systemctl start chatty-app
Auto-restart on Failure
Already configured in docker-compose.yaml:
restart: unless-stopped
Containers will automatically restart unless manually stopped.
Best Practices
Regular Operations
- Monitor logs daily
- Check resource usage weekly
- Review disk space weekly
- Test backups monthly
- Update services as needed
Security
- Rotate credentials regularly
- Update certificates before expiry
- Review access logs for anomalies
- Keep Docker updated
- Monitor security advisories
Performance
- Monitor response times
- Watch resource trends
- Clean up old data
- Optimize queries if needed
- Scale resources proactively
Monitoring Checklist
Daily:
- All containers running
- No error logs
- Application accessible
- Response times normal
Weekly:
- Resource usage trends
- Disk space available
- Log file sizes
- Backup success
Monthly:
- Test restore procedure
- Review security logs
- Update documentation
- Plan capacity
Next Steps
- Logs & Monitoring - Detailed logging guide
- Backup & Restore - Data protection
- Troubleshooting - Problem resolution
- Upgrades - Version updates