Skip to content

Application warmup hooks (LARAVEL_OPTIMIZE pattern, but generic) #7

@sylvesterdamgaard

Description

@sylvesterdamgaard

Motivation

LARAVEL_OPTIMIZE_ENABLED already runs config:cache route:cache view:cache at startup. Other apps need similar pre-flight work:

  • Statamic: php please stache:warm (without it, first request is 500 / 30s+)
  • WordPress with object cache: wp cache flush after cache-driver swap
  • Custom apps: php artisan custom:warmup, make seed, etc.

Right now there's no clean way to add app-specific warmup commands without writing a custom entrypoint and giving up cbox-init's lifecycle.

Proposal

Two complementary additions:

1. Generic APP_WARMUP_COMMANDS env var

APP_WARMUP_COMMANDS="php please stache:warm; php artisan event:cache"

Semicolon-separated. Run sequentially before the HTTP listener is marked ready. Failure surfaces in logs but is configurable (APP_WARMUP_ALLOW_FAILURE, mirroring LARAVEL_MIGRATE_ALLOW_FAILURE).

2. Framework-aware shortcuts (optional sugar)

  • STATAMIC_STACHE_WARM=true
  • STATAMIC_STATIC_WARM=true

Mirrors the existing LARAVEL_* pattern.

Acceptance criteria

  • APP_WARMUP_COMMANDS runs before health checks start succeeding
  • Failures logged with structured fields (process: warmup)
  • APP_WARMUP_ALLOW_FAILURE honoured
  • Documented alongside LARAVEL_OPTIMIZE_ENABLED

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions