azu dev
The azu dev
command provides an enhanced development environment with additional tools and features for productive development. It's an alternative to azu serve
with extra development capabilities.
Overview
azu dev [options]
Basic Usage
Start Development Environment
# Start development environment
azu dev
# Start with custom port
azu dev --port 4000
# Start with specific environment
azu dev --env development
Development with Hot Reloading
# Start development server with enhanced features
azu dev
# Output:
# π Starting Azu development environment...
# π¦ Compiling application...
# β
Compilation successful!
# π Server running at: http://localhost:3000
# π₯ Hot reloading enabled
# π Watching for file changes...
# π Development dashboard at: http://localhost:3000/dev
# π§ͺ Test runner available
# π Code formatter active
#
# Press Ctrl+C to stop the server
Command Options
--port <port>
Server port
3000
--host <host>
Server host
localhost
--env <environment>
Environment name
development
--debug
Enable debug mode
true
--dashboard
Enable development dashboard
true
--tests
Enable test runner
true
--format
Enable code formatting
true
--lint
Enable linting
true
--coverage
Enable code coverage
false
--workers <number>
Number of worker processes
1
Development Features
Development Dashboard
Access the development dashboard at http://localhost:3000/dev
:
# Dashboard features:
# - Application status
# - Database information
# - Route listing
# - Performance metrics
# - Error logs
# - Test results
# - Code coverage
Enhanced File Watching
# Watches additional file types
src/
βββ *.cr # Crystal source files
βββ endpoints/ # Endpoint files
βββ models/ # Model files
βββ services/ # Service files
βββ middleware/ # Middleware files
βββ initializers/ # Initializer files
βββ pages/ # Page components
public/
βββ assets/ # Static assets
βββ templates/ # Template files
βββ *.css, *.js, *.html # Static files
config/
βββ *.yml # Configuration files
βββ environments/ # Environment configs
spec/
βββ *_spec.cr # Test files
βββ factories/ # Test factories
Automatic Code Formatting
# Automatically format code on save
# Uses crystal tool format
# Format specific files
crystal tool format src/models/user.cr
# Format entire project
crystal tool format src/
Linting and Code Quality
# Run Ameba linter automatically
# Checks for code quality issues
# Manual linting
ameba src/
# Fix auto-fixable issues
ameba --fix src/
Test Runner Integration
# Run tests automatically on file changes
# Tests run in background
# Manual test execution
crystal spec
# Run specific test files
crystal spec spec/models/user_spec.cr
# Run with coverage
crystal spec --coverage
Development Dashboard
Dashboard Features
Application Status:
Server uptime
Memory usage
CPU usage
Request count
Error rate
Database Information:
Connection status
Migration status
Table count
Query performance
Route Listing:
All registered routes
HTTP methods
Endpoint classes
Route parameters
Performance Metrics:
Response times
Throughput
Memory allocation
Garbage collection
Error Logs:
Recent errors
Stack traces
Error frequency
Error categories
Test Results:
Test status
Coverage reports
Failed tests
Test performance
Accessing Dashboard
# Start development server
azu dev
# Access dashboard
# http://localhost:3000/dev
# Dashboard sections:
# /dev/status - Application status
# /dev/database - Database information
# /dev/routes - Route listing
# /dev/performance - Performance metrics
# /dev/errors - Error logs
# /dev/tests - Test results
# /dev/coverage - Code coverage
Examples
Basic Development
# Start development environment
azu dev
# Visit application
# http://localhost:3000
# Visit dashboard
# http://localhost:3000/dev
Custom Configuration
# Development with custom settings
azu dev --port 4000 --host 0.0.0.0 --debug
# Development without dashboard
azu dev --dashboard=false
# Development with coverage
azu dev --coverage
Team Development
# Share development server
azu dev --host 0.0.0.0 --port 3000
# Multiple developers can access:
# http://your-ip:3000
# http://your-ip:3000/dev
Development Workflow
1. Start Development
# Start development environment
azu dev
# In another terminal, run additional tools
crystal spec --watch
ameba --watch src/
2. Make Changes
# Edit files in src/
# Changes are automatically detected
# Server recompiles and restarts
# Tests run automatically
# Code is formatted
# Linting runs
3. Monitor Progress
# Check dashboard for:
# - Compilation status
# - Test results
# - Performance metrics
# - Error logs
# Visit: http://localhost:3000/dev
4. Debug Issues
# Check error logs in dashboard
# http://localhost:3000/dev/errors
# Check test failures
# http://localhost:3000/dev/tests
# Check performance issues
# http://localhost:3000/dev/performance
Advanced Features
Code Coverage
# Enable coverage tracking
azu dev --coverage
# View coverage in dashboard
# http://localhost:3000/dev/coverage
# Coverage includes:
# - Line coverage
# - Branch coverage
# - Function coverage
# - File coverage
Performance Profiling
# Enable performance profiling
azu dev --profile
# Profile information available in dashboard
# http://localhost:3000/dev/performance
# Profile data includes:
# - Request timing
# - Database queries
# - Memory usage
# - CPU usage
Database Monitoring
# Database monitoring in dashboard
# http://localhost:3000/dev/database
# Database information includes:
# - Connection status
# - Migration status
# - Query count
# - Query timing
# - Table sizes
Error Tracking
# Error tracking in dashboard
# http://localhost:3000/dev/errors
# Error information includes:
# - Error count
# - Error types
# - Stack traces
# - Error frequency
# - Error context
Configuration
Development Configuration
# config/environments/development.cr
Azu.configure do |config|
config.debug = true
config.log_level = :debug
config.host = "localhost"
config.port = 3000
# Development-specific settings
config.development.dashboard = true
config.development.auto_format = true
config.development.auto_lint = true
config.development.test_runner = true
config.development.coverage = false
end
Dashboard Configuration
# azu.yml
development:
dashboard:
enabled: true
port: 3000
host: localhost
auth: false
metrics:
enabled: true
interval: 5s
tests:
enabled: true
auto_run: true
coverage:
enabled: false
threshold: 80
Troubleshooting
Dashboard Not Accessible
# Check if dashboard is enabled
azu dev --dashboard=true
# Check dashboard port
# Default: http://localhost:3000/dev
# Check firewall settings
# Ensure port is accessible
Tests Not Running
# Check test configuration
azu dev --tests=true
# Run tests manually
crystal spec
# Check test files exist
ls -la spec/
Code Formatting Issues
# Check Crystal installation
crystal --version
# Run formatter manually
crystal tool format src/
# Check for syntax errors
crystal build src/main.cr
Performance Issues
# Reduce worker processes
azu dev --workers 1
# Disable features
azu dev --coverage=false --profile=false
# Check system resources
top
htop
Best Practices
1. Development Workflow
# Use azu dev for development
azu dev
# Use azu serve for simple testing
azu serve
# Use production build for performance testing
crystal build src/main.cr --release
2. Dashboard Usage
# Monitor dashboard regularly
# http://localhost:3000/dev
# Check for:
# - Compilation errors
# - Test failures
# - Performance issues
# - Database problems
3. Code Quality
# Keep code formatted
# crystal tool format runs automatically
# Fix linting issues
# ameba runs automatically
# Maintain test coverage
# Tests run automatically
4. Performance Monitoring
# Monitor performance in dashboard
# http://localhost:3000/dev/performance
# Watch for:
# - Slow requests
# - High memory usage
# - Database bottlenecks
# - Error spikes
Integration with IDEs
VS Code Integration
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Azu Dev",
"type": "crystal",
"request": "launch",
"program": "${workspaceFolder}/src/main.cr",
"args": ["dev", "--port", "3000"]
}
]
}
JetBrains Integration
# Run configuration
# Program: src/main.cr
# Arguments: dev --port 3000
# Working directory: project root
The azu dev
command provides an enhanced development environment with dashboard, testing, formatting, and monitoring capabilities.
Next Steps:
Development Workflows - Learn development patterns
Testing Your Application - Comprehensive testing
Database Commands - Manage your database
Last updated