azu serve

The azu serve command starts the development server with hot reloading capabilities. This is the primary command for development, automatically recompiling and restarting your application when files change.

Overview

azu serve [options]

Basic Usage

Start Development Server

# Start server on default port (4000)
azu serve

# Start on custom port
azu serve --port 4000

# Start with specific environment
azu serve --env development

Development with Hot Reloading

# Start server with file watching
azu serve

# Output:
# πŸš€ Starting Azu development server...
# πŸ“¦ Compiling application...
# βœ… Compilation successful!
# 🌐 Server running at: http://localhost:4000
# πŸ”₯ Hot reloading enabled
# πŸ‘€ Watching for file changes...
#
# Press Ctrl+C to stop the server

Command Options

Option
Description
Default

--port <port>

Server port

4000

--host <host>

Server host

localhost

--no-watch

Disable file watching

false

--verbose

Enable verbose output

false

Development Server Features

Hot Reloading

The development server automatically detects file changes and recompiles your application:

Watched File Patterns:

  • src/**/*.cr - Crystal source files

  • config/**/*.cr - Configuration files

  • public/templates/**/*.jinja - Jinja templates

  • public/templates/**/*.html - HTML templates

  • public/assets/**/*.css - CSS files

  • public/assets/**/*.js - JavaScript files

Error Reporting

The server provides detailed error information during development:

Environment Configuration

Server Configuration

Port and Host

Verbose Mode

File Watching

Automatic File Detection

The server watches for changes in:

Manual File Watching

Performance Options

Worker Processes

Memory and CPU Limits

Environment-Specific Configuration

Development Environment

Production Environment

Examples

Basic Development

Custom Configuration

Team Development

Mobile Development

Troubleshooting

Port Already in Use

Compilation Errors

File Watching Issues

Memory Issues

SSL Certificate Issues

Best Practices

1. Development Workflow

2. Environment Management

3. Performance Optimization

4. Security

5. Monitoring

Integration with Other Tools

VS Code Integration

Docker Development


The azu serve command is essential for Azu development, providing a fast, reliable development server with hot reloading capabilities.

Next Steps:

Last updated