Drush Commands
This guide covers Drush commands for monitoring, managing, and troubleshooting TMGMT Lara Translate with Symfony Messenger.
Core Commands
Message Management
messenger:consume
Consume messages from the message queue.
# Basic consumption
drush messenger:consume async
# Specific number of messages
drush messenger:consume async --limit=50
# Run with time limit
drush messenger:consume async --time-limit=300
# Set memory limit
drush messenger:consume async --memory-limit=512M
# Continuous processing with sleep
drush messenger:consume async --sleep=5
# Run in background
nohup drush messenger:consume async > /tmp/messenger.log &
messenger:info
Display information about message transports and handlers.
# Show all messenger information
drush messenger:info
# Show specific transport
drush messenger:info --transport=async
# Show handlers only
drush messenger:list-handlers
messenger:clear
Clear messages from a specific transport.
# Clear all async messages
drush messenger:clear async
# Clear specific transport
drush messenger:clear --transport=async
messenger:stats
Show statistics about message processing.
# Basic statistics
drush messenger:stats
# Statistics for specific transport
drush messenger:stats --transport=async
# JSON output for parsing
drush messenger:stats --format=json
TMGMT Commands
tmgmt-job:list
List translation jobs with filtering options.
# List all jobs
drush tmgmt-job:list
# Filter by status
drush tmgmt-job:list --status=active
# Filter by translator
drush tmgmt-job:list --translator=lara_translate
# Show specific job
drush tmgmt-job:show 123
# Output in YAML format
drush tmgmt-job:list --format=yaml
# Output with job items
drush tmgmt-job:list --items
tmgmt-job-item:list
List individual translation job items.
# List all job items
drush tmgmt-job-item:list
# Filter by job
drush tmgmt-job-item:list --job=456
# Filter by status
drush tmgmt-job-item:list --status=active
# Show item details
drush tmgmt-job-item:show 789
# Output word counts
drush tmgmt-job-item:list --field=word_count
Monitoring Commands
System Status
watchdog:show
Display recent log messages.
# Show recent tmgmt_laratranslate logs
drush watchdog:show --type=tmgmt_laratranslate
# Error logs only
drush watchdog:show --severity=error --type=tmgmt_laratranslate
# Real-time log following
drush watchdog:tail --type=tmgmt_laratranslate
# Filter by date range
drush watchdog:show --since="2025-01-01" --type=tmgmt_laratranslate
status
Check overall system status.
# Full system status
drush status
# PHP information only
drush status --format=json | jq '.php'
# Memory usage
drush status --format=json | jq '.["php-memory"]'
# Database connection
drush sql:query "SELECT CONNECTION_ID()" --database=drupal
Performance Monitoring
echo
Monitor system resources and queue metrics.
# Custom status script
echo "=== TMGMT Lara Translate Status ==="
echo "Active Jobs: $(drush tmgmt-job:list --status=active --format=yaml | yq '. | length')"
echo "Pending Messages: $(drush messenger:stats --format=yaml | yq '.pending')"
echo "Recent Errors: $(drush watchdog:show --severity=error --type=tmgmt_laratranslate --limit=1 --format=yaml | yq '. | length')"
Configuration Commands
config:get
View current configuration values.
# Show all messenger settings
drush config:get messenger.settings
# Show translator configuration
drush config:get tmgmt.translator.lara_translate
# Show specific setting
drush config:get tmgmt.translator.lara_translate --format=yaml
# Show custom language mappings
drush config:get tmgmt.translator.lara_translate --key=language_mappings
config:set
Update configuration values.
# Set Redis transport
drush config:set messenger.settings transports.async 'redis://localhost:6379/messages'
# Set custom language mapping
drush config:set tmgmt.translator.lara_translate language_mappings.en 'en-GB'
# Set worker time limit
drush config:set messenger.settings.consumers.async.time_limit 300
# Enable debug logging
drush config:set system.logging error_level verbose
config:export
Export configuration for backup or migration.
# Export all settings
drush config:export --directory=/tmp/backup
# Export messenger settings
drush config:export --directory=/tmp/backup --key=messenger.settings
Advanced Commands
Testing and Debugging
php
Execute PHP code within Drupal context.
# Test language mapping
drush php -r "
\$translator = \Drupal::entityTypeManager()->getStorage('tmgmt_translator')->load('lara_translate');
\$plugin = \$translator->getPlugin();
echo \$plugin->mapDrupalToLaraLanguage('en', \$translator);
"
# Test service availability
drush php -r "
\$splitter = \Drupal::service('Drupal\tmgmt_laratranslate\Service\RecursiveCharacterTextSplitter');
echo get_class(\$splitter);
"
php:script
Execute PHP script files.
# Run custom test script
drush php:script check_translations.php
# Script with arguments
drush php:script process_job.php --job-id=123 --verbose
Command Reference Table
| Command | Purpose | Key Options | Example |
|---|---|---|---|
messenger:consume |
Process message queue | --limit, --time-limit, --memory-limit |
drush messenger:consume async --limit=100 |
messenger:info |
Show messenger status | --transport, --handlers |
drush messenger:info --transport=async |
messenger:stats |
Display processing statistics | --format=json, --transport |
drush messenger:stats --format=yaml |
messenger:clear |
Clear message queue | --transport |
drush messenger:clear async |
tmgmt-job:list |
List translation jobs | --status, --translator, --items |
drush tmgmt-job:list --status=active |
tmgmt-job-item:list |
List job items | --job, --status |
drush tmgmt-job-item:list --job=456 |
watchdog:show |
View system logs | --type, --severity, --limit |
drush watchdog:show --type=tmgmt_laratranslate --severity=error |
config:get |
View configuration | --key, --format |
drush config:get messenger.settings |
config:set |
Update configuration | --key, --value |
drush config:set messenger.settings transport.async redis://localhost:6379 |
Workflow Examples
Daily Monitoring
#!/bin/bash
# daily_monitoring.sh
echo "=== Daily TMGMT Status Report ==="
# Check active jobs
ACTIVE_JOBS=$(drush tmgmt-job:list --status=active --format=yaml | yq '. | length')
echo "Active Jobs: $ACTIVE_JOBS"
# Check message queue
PENDING_MSGS=$(drush messenger:stats --format=yaml | yq '.pending')
echo "Pending Messages: $PENDING_MSGS"
# Check recent errors
ERROR_COUNT=$(drush watchdog:show --severity=error --type=tmgmt_laratranslate --limit=24 | wc -l)
echo "Recent Errors (24h): $ERROR_COUNT"
# Alert on issues
if [ $ERROR_COUNT -gt 5 ]; then
echo "⚠️ High error rate detected"
# Send notification logic here
fi
Worker Management
#!/bin/bash
# worker_manager.sh
# Start 4 workers
for i in {1..4}; do
echo "Starting worker $i"
nohup drush messenger:consume async \
--worker-id=$i \
--time-limit=3600 \
--memory-limit=256M \
> /var/log/tmgmt-worker-$i.log &
sleep 2
done
echo "All workers started"
# Monitor workers
watch "ps aux | grep 'drush messenger:consume'"
Automated Health Check
#!/bin/bash
# health_check.sh
# Test message processing
TEST_MESSAGE=$(drush messenger:consume async --limit=1 --verbose 2>&1 | grep "messages processed")
if [ -n "$TEST_MESSAGE" ]; then
echo "✅ Message processing working"
else
echo "❌ Message processing failed"
exit 1
fi
# Test translation service
TRANSLATOR_STATUS=$(drush tmgmt:translator-info lara_translate --format=yaml | yq '.available')
if [ "$TRANSLATOR_STATUS" = "true" ]; then
echo "✅ Lara translator available"
else
echo "❌ Lara translator not available"
fi
Output Formats
Table Format
# Human-readable table output
drush tmgmt-job:list --format=table
# Custom fields
drush tmgmt-job-item:list --field=id,status,word_count --format=table
YAML Format
# Machine-readable output
drush messenger:stats --format=yaml
# Pipe to other commands
drush config:export --directory=- | yq '.messenger.settings'
JSON Format
# Integration with monitoring systems
drush messenger:stats --format=json | jq '.pending, .processing, .failed'
Troubleshooting Commands
Debug Mode
# Enable verbose output
drush messenger:consume async --verbose
# Show debugging information
drush php -r "var_dump(\$this->config);" --debug
# Test message processing
drush messenger:consume async --limit=1 --dry-run
Common Issues
Command Not Found
# Check if commands are available
drush list | grep messenger
# Verify module installation
drush pm:status | grep tmgmt_laratranslate
# Clear command cache
drush cache:rebuild
Permission Errors
# Run with appropriate user
sudo -u www-data drush messenger:consume async
# Check file permissions
ls -la /var/log/tmgmt-worker.log
# Check Drupal permissions
drush user:info
Performance Tips
Efficient Commands
# Use output piping
drush tmgmt-job:list --format=yaml | yq '.[] | select(.status == "active") | length'
# Limit results
drush watchdog:show --limit=100
# Use specific filters
drush messenger:stats --transport=async
Batch Operations
# Process multiple job items
drush tmgmt-job-item:complete $(drush tmgmt-job-item:list --status=needs_review --format=yaml | yq '.[].job_item_id')
# Approve multiple jobs
for job_id in $(drush tmgmt-job:list --status=completed --format=yaml | yq '.[].job_id'); do
drush tmgmt-job:approve $job_id
done
Related Documentation
- Cron Setup Guide - Production deployment details
- Monitoring Guide - Status tracking and health checks
- Architecture Guide - Symfony Messenger implementation
- Troubleshooting Guide - Common issues and solutions