This guide explains how to run the Pale Fire AI Agent daemon using Docker.
Note: All docker-compose commands should be run from the palefire root directory (parent of agents/).
The AI Agent daemon keeps Gensim and spaCy models loaded in memory to eliminate start/stop delays. This is essential for production deployments where models need to be ready instantly for keyword extraction and entity recognition.
Run the AI Agent as a standalone service:
# Build and start the agent (run from palefire root directory)
docker-compose -f agents/docker-compose.agent.yml up -d
# View logs
docker-compose -f agents/docker-compose.agent.yml logs -f
# Stop the agent
docker-compose -f agents/docker-compose.agent.yml downRun the AI Agent alongside the main Pale Fire services:
# Start all services including the agent
docker-compose -f docker-compose.yml -f agents/docker-compose.agent.yml up -d
# View agent logs
docker-compose -f agents/docker-compose.agent.yml logs -f palefire-agent
# Stop only the agent
docker-compose -f agents/docker-compose.agent.yml stop palefire-agentThe following environment variables can be configured:
| Variable | Default | Description |
|---|---|---|
PALEFIRE_PIDFILE |
/tmp/palefire_ai_agent.pid |
Path to PID file |
PALEFIRE_USE_SPACY |
true |
Enable spaCy for NER |
PALEFIRE_DAEMON |
true |
Run in daemon mode |
LOG_LEVEL |
INFO |
Logging level |
NLTK_DATA |
/root/nltk_data |
Path to NLTK data |
Edit agents/docker-compose.agent.yml to customize:
services:
palefire-agent:
environment:
- PALEFIRE_USE_SPACY=false # Disable spaCy for faster startup
- LOG_LEVEL=DEBUG # Enable debug loggingBuild the agent image manually:
# Build the image (run from palefire root directory)
docker build -f agents/Dockerfile.agent -t palefire-agent:latest .
# Run the container (run from palefire root directory)
docker run -d \
--name palefire-ai-agent \
-v $(pwd)/logs:/app/logs \
-e PALEFIRE_USE_SPACY=true \
palefire-agent:latestThe container includes a health check that verifies the agent process is running:
# Check container health
docker ps
# View health check logs
docker inspect palefire-ai-agent | grep -A 10 HealthView agent logs:
# Follow logs
docker-compose -f agents/docker-compose.agent.yml logs -f palefire-agent
# View last 100 lines
docker-compose -f agents/docker-compose.agent.yml logs --tail=100 palefire-agent
# View logs from Docker directly
docker logs -f palefire-ai-agentThe following volumes are mounted (paths relative to palefire root directory):
../logs:/app/logs- Application logs../data:/app/data- Data directory (optional)
The agent runs on its own network (palefire-network).
To connect the agent to the main Pale Fire network:
-
Start the main services first:
docker-compose up -d
-
Update
agents/docker-compose.agent.yml:networks: palefire-network: external: true name: palefire-network
-
Start the agent:
docker-compose -f agents/docker-compose.agent.yml up -d
Check logs:
docker-compose -f agents/docker-compose.agent.yml logs palefire-agentVerify spaCy model is installed:
docker exec palefire-ai-agent python -m spacy info en_core_web_smCheck if the process is running:
docker exec palefire-ai-agent ps aux | grep palefire-agentEnsure the container has write access to mounted volumes:
docker exec palefire-ai-agent ls -la /app/logsAdd resource limits to agents/docker-compose.agent.yml:
services:
palefire-agent:
deploy:
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '1'
memory: 2GThe default restart policy is unless-stopped. For production:
services:
palefire-agent:
restart: alwaysConfigure log rotation:
services:
palefire-agent:
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"The AI Agent can be used by the main Pale Fire API service. To enable this:
- Ensure both services are on the same network
- The API can connect to the agent via the network
- Or use the agent's programmatic interface directly
Example API integration:
from agents import get_daemon
# Initialize daemon (models loaded once)
daemon = get_daemon(use_spacy=True)
daemon.model_manager.initialize(use_spacy=True)
# Use in API endpoints
@app.post("/keywords")
async def extract_keywords(request: KeywordExtractionRequest):
keywords = daemon.extract_keywords(
request.text,
method=request.method.value,
num_keywords=request.num_keywords
)
return {"keywords": keywords}Monitor the agent process:
docker exec palefire-ai-agent ps aux | grep pythonMonitor resource usage:
docker stats palefire-ai-agentSet up log aggregation:
# Using docker logs
docker logs -f palefire-ai-agent | grep ERROR
# Using compose
docker-compose -f agents/docker-compose.agent.yml logs -f | grep ERRORTo update the agent:
# Pull latest code
git pull
# Rebuild and restart
docker-compose -f agents/docker-compose.agent.yml up -d --buildRemove the agent container and volumes:
# Stop and remove container
docker-compose -f agents/docker-compose.agent.yml downdocker rmi palefire-agent:latest
docker volume ls | grep palefire docker volume rm