Skip to content

Commit f5babb0

Browse files
docs: fix stale references to get_vars lazy-start
get_vars is now pure-read; the lazy-start lives in require_background_worker. Updated the How It Works steps, the named/catch-all bullets in Configuration, and the Caddyfile comment that described the catch-all as "handles any unlisted name via get_vars()".
1 parent f669192 commit f5babb0

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

docs/background-workers.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ They observe their environment and publish variables that HTTP threads (both [wo
77

88
1. A background worker runs its own event loop (subscribe to Redis, watch files, poll an API...)
99
2. It calls `frankenphp_set_vars()` to publish a snapshot of key-value pairs
10-
3. HTTP threads call `frankenphp_get_vars()` to read the latest snapshot
11-
4. The first `get_vars()` call blocks until the background worker has published - no startup race condition
10+
3. HTTP threads call `frankenphp_require_background_worker()` to declare a dependency and ensure the worker is running (lazy-started if needed, blocks until it has published at least once)
11+
4. HTTP threads then call `frankenphp_get_vars()` to read the latest snapshot (pure read, no blocking)
1212

1313
## Configuration
1414

@@ -27,16 +27,16 @@ example.com {
2727
name feature-flags
2828
}
2929
30-
# Catch-all - handles any unlisted name via get_vars()
30+
# Catch-all - handles any unlisted name via require_background_worker()
3131
worker /app/bin/console {
3232
background
3333
}
3434
}
3535
}
3636
```
3737

38-
- **Named** (with `name`): lazy-started on first `get_vars()` call, or auto-started at boot if `num 1` is set.
39-
- **Catch-all** (no `name`): also lazy-started. Use `max_threads` to cap how many can be created (defaults to 16). Not declaring a catch-all forbids unlisted names.
38+
- **Named** (with `name`): lazy-started on first `require_background_worker()` call, or auto-started at boot if `num 1` is set.
39+
- **Catch-all** (no `name`): lazy-started on demand too, for any name not matched by a `name` directive. Use `max_threads` to cap how many can be created (defaults to 16). Not declaring a catch-all forbids unlisted names.
4040
- Each `php_server` block has its own isolated scope - two blocks can use the same worker names without conflict.
4141
- `max_consecutive_failures`, `env`, and `watch` work the same as HTTP workers.
4242

@@ -241,5 +241,5 @@ if (function_exists('frankenphp_get_vars')) {
241241
- `$_SERVER['FRANKENPHP_WORKER_NAME']` is set for all workers (HTTP and background)
242242
- `$_SERVER['FRANKENPHP_WORKER_BACKGROUND']` is `true` for background workers, `false` for HTTP workers
243243
- `$_SERVER['argv']` = `[entrypoint, name]` in background workers (for `bin/console` compatibility)
244-
- Crash recovery with automatic restart and exponential backoff. During the restart window, `get_vars` returns the last published data (stale but available). A warning is logged on crash (`background worker exited, restarting`).
244+
- Crash recovery with automatic restart and exponential backoff. During the restart window, `get_vars()` returns the last published data (stale but available) since the vars stay in persistent memory across crashes. A warning is logged on crash (`background worker exited, restarting`).
245245
- On shutdown/restart: the signaling stream is closed (EOF). Workers have 5 seconds to exit. Stuck workers are force-killed on Linux and Windows.

0 commit comments

Comments
 (0)