A microservices framework for Python that lets service developers concentrate on application logic and encourages testability
—
Command-line interface for running, managing, and interacting with nameko services in development and production environments.
The nameko command provides the primary interface for service management and development tasks.
nameko <command> [options]Available Commands:
run - Run nameko servicesshell - Interactive shell for testing servicesshow-config - Display service configurationbackdoor - Start backdoor server for debuggingStart one or more nameko services from Python modules.
nameko run <module>[:<ServiceClass>] [options]
Options:
--config <file> Configuration file path
--broker <url> AMQP broker URL
--backdoor-port <port> Enable backdoor on specified port
--rlimits <limits> Set resource limitsUsage Examples:
# Run all services from a module
nameko run myproject.services
# Run specific service class
nameko run myproject.services:UserService
# Run with custom configuration
nameko run myproject.services --config config.yaml
# Run with custom broker
nameko run myproject.services --broker amqp://guest:guest@localhost:5672//
# Run multiple services
nameko run myproject.user_service myproject.email_service
# Run with backdoor for debugging
nameko run myproject.services --backdoor-port 3000
# Run with resource limits
nameko run myproject.services --rlimits "nofile=10000,nproc=500"Start an interactive Python shell with RPC proxy for testing services.
nameko shell [options]
Options:
--config <file> Configuration file path
--broker <url> AMQP broker URL
--interface <type> Shell interface ('bpython', 'ipython', 'plain')Usage Examples:
# Start interactive shell
nameko shell
# Shell with custom configuration
nameko shell --config config.yaml
# Shell with custom broker
nameko shell --broker amqp://guest:guest@localhost:5672//
# Use specific shell interface
nameko shell --interface ipythonShell Environment:
When you start the nameko shell, the following objects are available:
# Available in shell namespace
n # RPC proxy cluster for calling services
config # Current configuration
make_proxy # Function to create RPC proxies
# Example usage in shell
>>> n.user_service.get_user(123)
{'id': 123, 'name': 'John Doe'}
>>> n.email_service.send_email('user@example.com', 'Hello!')
{'status': 'sent'}
# Create custom proxy with timeout
>>> proxy = make_proxy('user_service', timeout=10)
>>> proxy.get_user(456)Show the resolved configuration for services.
nameko show-config [options]
Options:
--config <file> Configuration file path
--format <format> Output format ('yaml', 'json')Usage Examples:
# Show default configuration
nameko show-config
# Show configuration from file
nameko show-config --config production.yaml
# Output as JSON
nameko show-config --format json
# Output as YAML (default)
nameko show-config --format yamlStart a backdoor server for runtime debugging and inspection.
nameko backdoor [options]
Options:
--config <file> Configuration file path
--backdoor-port <port> Port for backdoor server (default: 3000)Usage Examples:
# Start backdoor on default port
nameko backdoor
# Start on custom port
nameko backdoor --backdoor-port 8000
# Connect to backdoor
telnet localhost 3000Backdoor Environment:
The backdoor provides access to:
# Available in backdoor namespace
services # Dictionary of running service containers
config # Service configuration
n # RPC proxy clusterConfiguration can be provided via YAML or JSON files.
YAML Configuration Example:
# config.yaml
AMQP_URI: "amqp://guest:guest@localhost:5672//"
WEB_SERVER_ADDRESS: "0.0.0.0:8000"
# Service-specific configuration
DATABASE_URL: "postgresql://user:pass@localhost/mydb"
REDIS_URL: "redis://localhost:6379/0"
# Logging configuration
LOGGING:
version: 1
handlers:
console:
class: logging.StreamHandler
level: INFO
root:
level: INFO
handlers: [console]
# Custom service settings
EMAIL_SETTINGS:
smtp_host: "smtp.gmail.com"
smtp_port: 587
use_tls: trueJSON Configuration Example:
{
"AMQP_URI": "amqp://guest:guest@localhost:5672//",
"WEB_SERVER_ADDRESS": "0.0.0.0:8000",
"DATABASE_URL": "postgresql://user:pass@localhost/mydb",
"MAX_WORKERS": 10,
"RPC_TIMEOUT": 30
}Configuration values can be overridden with environment variables.
# Set AMQP broker via environment
export AMQP_URI="amqp://user:pass@broker-host:5672//"
# Set web server address
export WEB_SERVER_ADDRESS="0.0.0.0:8080"
# Set custom configuration
export DATABASE_URL="postgresql://localhost/production_db"
# Run with environment variables
nameko run myproject.servicesCommon CLI patterns for development.
# Development server with auto-reload (using external tools)
watchmedo auto-restart --directory=./myproject --pattern=*.py --recursive -- nameko run myproject.services
# Run services with debugging
nameko run myproject.services --backdoor-port 3000
# Test services interactively
nameko shell --config dev-config.yaml
# Check configuration
nameko show-config --config dev-config.yaml
# Production deployment
nameko run myproject.services --config production.yaml --rlimits "nofile=65536"CLI options for logging and service monitoring.
# Run with verbose logging
NAMEKO_LOG_LEVEL=DEBUG nameko run myproject.services
# Log to file
nameko run myproject.services 2>&1 | tee service.log
# Run with structured logging
nameko run myproject.services --config logging-config.yamlLogging Configuration:
# logging-config.yaml
LOGGING:
version: 1
formatters:
default:
format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
json:
format: '{"timestamp": "%(asctime)s", "service": "%(name)s", "level": "%(levelname)s", "message": "%(message)s"}'
handlers:
console:
class: logging.StreamHandler
formatter: default
level: INFO
file:
class: logging.FileHandler
filename: service.log
formatter: json
level: DEBUG
loggers:
nameko:
level: INFO
handlers: [console, file]
root:
level: WARNING
handlers: [console]CLI patterns for production process management.
# Run as daemon (using external process manager)
nohup nameko run myproject.services --config production.yaml &
# With systemd service
systemctl start nameko-services
systemctl enable nameko-services
# With supervisor
supervisorctl start nameko-services
# Docker deployment
docker run -d --name nameko-services \
-v /path/to/config.yaml:/config.yaml \
myproject:latest \
nameko run myproject.services --config /config.yaml
# Kubernetes deployment
kubectl apply -f nameko-deployment.yamlCLI commands for service health monitoring.
# Basic health check via shell
echo "n.health_service.check()" | nameko shell --config production.yaml
# Monitor service metrics
nameko shell --config production.yaml
>>> n.metrics_service.get_stats()
# Check service discovery
nameko shell
>>> # List available services by trying to call them
>>> import inspect
>>> for service in ['user_service', 'email_service', 'order_service']:
... try:
... print(f"{service}: {getattr(n, service).ping()}")
... except Exception as e:
... print(f"{service}: ERROR - {e}")Common CLI debugging techniques.
# Check configuration issues
nameko show-config --config problematic.yaml
# Debug with backdoor
nameko run myproject.services --backdoor-port 3000
# Connect: telnet localhost 3000
# Verbose logging for debugging
NAMEKO_LOG_LEVEL=DEBUG nameko run myproject.services
# Test individual service methods
nameko shell
>>> n.problematic_service.test_method()
# Check AMQP connectivity
nameko shell --broker amqp://test-broker:5672//
>>> n # Should connect or show errorInstall with Tessl CLI
npx tessl i tessl/pypi-nameko