Configure Production

This guide shows you how to configure your Azu application for production deployment.

Environment Configuration

Use environment variables for all settings:

module MyApp
  include Azu

  configure do
    port = ENV.fetch("PORT", "8080").to_i
    host = ENV.fetch("HOST", "0.0.0.0")

    case ENV.fetch("AZU_ENV", "development")
    when "production"
      log.level = Log::Severity::Info
      template_hot_reload = false
    when "test"
      log.level = Log::Severity::Warn
    else
      log.level = Log::Severity::Debug
      template_hot_reload = true
    end
  end
end

Environment Variables

Create a .env.example file (commit this):

Create .env.production (never commit):

Build for Production

Create an optimized release build:

SSL Configuration

Configure SSL in your application:

Security Headers

Add a security headers handler:

Logging Configuration

Configure production logging:

Health Check Endpoint

Add a health check for load balancers:

Graceful Shutdown

Handle shutdown signals:

Connection Pooling

Configure database connection pooling:

Rate Limiting

Add rate limiting for API protection:

Production Checklist

Before deploying:

See Also

Last updated

Was this helpful?