You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/background-workers.md
+25-24Lines changed: 25 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,9 @@ They observe their environment and publish configuration that HTTP [workers](wor
6
6
## How It Works
7
7
8
8
1. A background worker runs its own event loop (subscribe to Redis, watch files, poll an API...)
9
-
2. It calls `frankenphp_worker_set_vars()` to publish a snapshot of key-value pairs
10
-
3. HTTP workers call `frankenphp_worker_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
9
+
2. It calls `frankenphp_set_worker_state()` to publish a snapshot of key-value pairs
10
+
3. HTTP workers call `frankenphp_get_worker_state()` to read the latest snapshot
11
+
4. The first `get_worker_state()` call blocks until the background worker has published - no startup race condition
12
12
13
13
## Configuration
14
14
@@ -27,51 +27,52 @@ example.com {
27
27
name feature-flags
28
28
}
29
29
30
-
# Catch-all - handles any unlisted name via get_vars()
30
+
# Catch-all - handles any unlisted name via get_worker_state()
31
31
worker /app/bin/console {
32
32
background
33
33
}
34
34
}
35
35
}
36
36
```
37
37
38
-
-**Named** (with `name`): lazy-started on first `get_vars()` call, or auto-started at boot if `num 1` is set.
38
+
-**Named** (with `name`): lazy-started on first `get_worker_state()` call, or auto-started at boot if `num 1` is set.
39
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.
40
40
- Each `php_server` block has its own isolated scope - two blocks can use the same worker names without conflict.
41
41
-`max_consecutive_failures`, `env`, and `watch` work the same as HTTP workers.
@@ -201,5 +202,5 @@ if (function_exists('frankenphp_worker_get_vars')) {
201
202
-`$_SERVER['FRANKENPHP_WORKER_NAME']` is set for all workers (HTTP and background)
202
203
-`$_SERVER['FRANKENPHP_WORKER_BACKGROUND']` is `true` for background workers, `false` for HTTP workers
203
204
-`$_SERVER['argv']` = `[entrypoint, name]` in background workers (for `bin/console` compatibility)
204
-
- 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`).
205
+
- Crash recovery with automatic restart and exponential backoff. During the restart window, `get_worker_state` returns the last published data (stale but available). A warning is logged on crash (`background worker exited, restarting`).
205
206
- 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