CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-flower

Web-based tool for monitoring and administrating Celery clusters with real-time task tracking and worker management.

Pending
Overview
Eval results
Files

command-line.mddocs/

Command Line Interface

Command-line interface for starting and configuring Flower with extensive configuration options, environment variable support, and integration with Celery's command system.

Capabilities

Main Command Function

The primary entry point for the Flower command-line interface, integrated with Celery's command system.

@click.command(cls=CeleryCommand, context_settings={'ignore_unknown_options': True})
@click.argument("tornado_argv", nargs=-1, type=click.UNPROCESSED)
@click.pass_context
def flower(ctx, tornado_argv):
    """
    Web based tool for monitoring and administrating Celery clusters.
    
    Args:
        ctx: Click context object containing Celery app
        tornado_argv: Additional Tornado/Flower specific arguments
    """

Configuration Management

Functions for applying configuration from various sources including environment variables and configuration files.

def apply_env_options():
    """
    Apply configuration options from environment variables.
    
    Processes environment variables with FLOWER_ prefix and applies
    them to Tornado's options system. Handles type conversion and
    multiple value options.
    """

def apply_options(prog_name, argv):
    """
    Apply configuration options from command line and config file.
    
    Args:
        prog_name (str): Program name for argument parsing
        argv (list): Command line arguments to process
        
    Parses command line options and loads configuration file if specified.
    """

def setup_logging():
    """
    Configure logging system based on options.
    
    Sets up appropriate logging levels and handlers based on
    debug and logging configuration options.
    """

def extract_settings():
    """
    Extract and validate application settings from options.
    
    Processes authentication, SSL, and other settings, performing
    validation and applying defaults where necessary.
    """

Environment Variable Support

Flower supports extensive configuration through environment variables with the FLOWER_ prefix.

def is_flower_envvar(name):
    """
    Check if environment variable is a valid Flower option.
    
    Args:
        name (str): Environment variable name
        
    Returns:
        bool: True if variable name is valid Flower option
    """

# Environment variable prefix
ENV_VAR_PREFIX = 'FLOWER_'

Utility Functions

Helper functions for option validation, banner display, and argument processing.

def is_flower_option(arg):
    """
    Check if command line argument is a valid Flower option.
    
    Args:
        arg (str): Command line argument
        
    Returns:
        bool: True if argument is valid Flower option
    """

def print_banner(app, ssl):
    """
    Display startup banner with connection information.
    
    Args:
        app: Celery application instance
        ssl (bool): Whether SSL is enabled
        
    Prints server URL, broker information, and registered tasks.
    """

def warn_about_celery_args_used_in_flower_command(ctx, flower_args):
    """
    Warn about incorrectly placed Celery arguments.
    
    Args:
        ctx: Click context
        flower_args: Flower command arguments
        
    Warns users about Celery arguments that should come before flower command.
    """

Configuration Options

Server Configuration

Core server settings for network binding and protocol options.

# Basic server options
--port=5555                    # Server port (default: 5555)
--address=0.0.0.0             # Server address (default: 0.0.0.0)
--unix-socket=/path/socket    # Unix socket path
--url-prefix=/flower          # URL prefix for reverse proxy setups

# SSL/TLS options
--certfile=/path/cert.pem     # SSL certificate file
--keyfile=/path/key.pem       # SSL private key file
--ca-certs=/path/ca.pem       # SSL CA certificates

Authentication Options

Configure authentication methods and providers.

# Basic authentication
--basic-auth=user:password    # Basic HTTP authentication
--auth=user@domain.com        # Email-based authentication pattern

# OAuth2 providers
--auth=google|github|gitlab|okta
--oauth2-key=client_id        # OAuth2 client ID
--oauth2-secret=client_secret # OAuth2 client secret
--oauth2-redirect-uri=uri     # OAuth2 redirect URI

Performance and Storage Options

Configure memory limits, persistence, and performance settings.

# Memory management
--max-workers=5000            # Maximum workers in memory
--max-tasks=100000           # Maximum tasks in memory

# Persistence and storage
--persistent                  # Enable persistent mode
--db=/path/flower.db         # Database file path
--state-save-interval=60     # State save interval in seconds

# Inspection settings
--inspect-timeout=10000      # Worker inspection timeout (ms)

Monitoring and Integration Options

Configure event monitoring, broker API access, and external integrations.

# Event monitoring
--enable-events              # Auto-enable events on workers
--disable-events             # Disable event monitoring

# Broker API integration
--broker-api=http://guest:guest@localhost:15672/api/  # RabbitMQ API

# Logging and debugging
--debug                      # Enable debug mode
--logging=info|debug|warning # Set logging level

Usage Examples

Basic Usage

# Start with default settings
celery flower

# Specify broker and port
celery -b redis://localhost:6379 flower --port=5555

# With authentication
celery flower --basic-auth=admin:secret

# With SSL
celery flower --certfile=cert.pem --keyfile=key.pem

Environment Variable Configuration

# Set options via environment variables
export FLOWER_PORT=8888
export FLOWER_BASIC_AUTH=admin:password
export FLOWER_PERSISTENT=true
export FLOWER_MAX_WORKERS=1000

celery flower

Advanced Configuration

# Production setup with SSL and OAuth
celery -b redis://prod-redis:6379 flower \
  --port=443 \
  --certfile=/etc/ssl/flower.crt \
  --keyfile=/etc/ssl/flower.key \
  --auth=google \
  --oauth2-key=$GOOGLE_CLIENT_ID \
  --oauth2-secret=$GOOGLE_CLIENT_SECRET \
  --oauth2-redirect-uri=https://flower.company.com/login \
  --persistent \
  --max-workers=10000 \
  --broker-api=https://guest:guest@rabbitmq.company.com:15672/api/

Configuration File Usage

Create flowerconfig.py:

# Flower configuration file
port = 5555
address = "0.0.0.0"
basic_auth = ["admin:secret", "user:password"]
max_workers = 5000
persistent = True
db = "/var/lib/flower/flower.db"

Use with:

celery flower --conf=flowerconfig.py

Docker Usage

# Docker environment variables
docker run -d \
  -e FLOWER_PORT=5555 \
  -e FLOWER_BASIC_AUTH=admin:secret \
  -e FLOWER_PERSISTENT=true \
  -e CELERY_BROKER_URL=redis://redis:6379 \
  -p 5555:5555 \
  myapp-flower

Integration with Celery Commands

Standard Celery Integration

Flower integrates as a Celery command, allowing use of all Celery options:

# Use Celery app and broker settings
celery -A myapp worker &         # Start worker
celery -A myapp flower           # Start Flower monitoring

# With broker specification
celery -b redis://localhost:6379 flower

# With result backend
celery -b redis://localhost:6379 --result-backend=redis://localhost:6379 flower

Programmatic Integration

from celery.bin.celery import main, celery
from flower.command import flower

# Add flower command to Celery
celery.add_command(flower)

# Can now use: celery flower
if __name__ == "__main__":
    main()

Error Handling

The command-line interface includes comprehensive error handling:

  • Configuration file validation with helpful error messages
  • SSL certificate validation and path checking
  • Authentication option validation
  • Port and address binding error reporting
  • Environment variable type conversion error handling

Default Configuration

Flower includes sensible defaults for all options:

# Default configuration file name
DEFAULT_CONFIG_FILE = 'flowerconfig.py'

# Core defaults
default_options = {
    'port': 5555,
    'address': '0.0.0.0',
    'debug': False,
    'max_workers': 5000,
    'max_tasks': 100000,
    'inspect_timeout': 10000,
    'persistent': False,
    'enable_events': True,
    # ... additional defaults
}

Install with Tessl CLI

npx tessl i tessl/pypi-flower

docs

application.md

authentication.md

broker.md

command-line.md

events.md

index.md

rest-api.md

tasks.md

utilities.md

web-interface.md

workers.md

tile.json