Context
PR #141 introduced a CACHE_WARMUP_TIMEOUT constant (30 seconds) in Runner.php for the forked cache warmup process timeout. Currently this value is hardcoded and cannot be changed without modifying the source.
Architecture Note
Runner is NOT a container service — it is created by Runtime::getRunner() before the DI container is available. Bundle config cannot reach Runner at runtime. The only reliable path is $_SERVER env var (same pattern as existing APP_CACHE_DIR).
Bundle config cache_warmup_timeout is added for documentation and to set the container parameter (usable by other services), but Runner reads exclusively from $_SERVER[WORKERMAN_CACHE_WARMUP_TIMEOUT] with a default fallback.
Implementation Plan
Task 1: Add cache_warmup_timeout to bundle configuration
Files: src/config/configuration.php, src/config/services.php
- Add config node in
src/config/configuration.php after stop_timeout:
->integerNode('cache_warmup_timeout')
->info('Max seconds to wait for cache warmup in forked process. Can be overridden with WORKERMAN_CACHE_WARMUP_TIMEOUT env var.')
->defaultValue(30)
->end()
- Add container parameter in
src/config/services.php:
$container->setParameter('workerman.cache_warmup_timeout', $config['cache_warmup_timeout']);
Task 2: Update Runner to use configurable timeout
Files: src/Runner.php
- Remove
CACHE_WARMUP_TIMEOUT constant
- Add
getCacheWarmupTimeout() method (mirrors getCacheDir() pattern):
private function getCacheWarmupTimeout(): int
{
if (isset($_SERVER['WORKERMAN_CACHE_WARMUP_TIMEOUT'])) {
return (int) $_SERVER['WORKERMAN_CACHE_WARMUP_TIMEOUT'];
}
return 30;
}
- Replace
$timeout = self::CACHE_WARMUP_TIMEOUT; with $timeout = $this->getCacheWarmupTimeout();
Task 3: Update tests
Files: tests/RunnerTest.php
- Replace
CACHE_WARMUP_TIMEOUT assertion with WORKERMAN_CACHE_WARMUP_TIMEOUT and getCacheWarmupTimeout
- Add
testCacheWarmupTimeoutDefaultsTo30 structural test
Task 4: Verify
- Run
vendor/bin/phpunit
- Run
vendor/bin/phpstan analyse
- Run
vendor/bin/php-cs-fixer fix --dry-run
References
Context
PR #141 introduced a
CACHE_WARMUP_TIMEOUTconstant (30 seconds) inRunner.phpfor the forked cache warmup process timeout. Currently this value is hardcoded and cannot be changed without modifying the source.Architecture Note
Runneris NOT a container service — it is created byRuntime::getRunner()before the DI container is available. Bundle config cannot reachRunnerat runtime. The only reliable path is$_SERVERenv var (same pattern as existingAPP_CACHE_DIR).Bundle config
cache_warmup_timeoutis added for documentation and to set the container parameter (usable by other services), butRunnerreads exclusively from$_SERVER[WORKERMAN_CACHE_WARMUP_TIMEOUT]with a default fallback.Implementation Plan
Task 1: Add
cache_warmup_timeoutto bundle configurationFiles:
src/config/configuration.php,src/config/services.phpsrc/config/configuration.phpafterstop_timeout:src/config/services.php:Task 2: Update
Runnerto use configurable timeoutFiles:
src/Runner.phpCACHE_WARMUP_TIMEOUTconstantgetCacheWarmupTimeout()method (mirrorsgetCacheDir()pattern):$timeout = self::CACHE_WARMUP_TIMEOUT;with$timeout = $this->getCacheWarmupTimeout();Task 3: Update tests
Files:
tests/RunnerTest.phpCACHE_WARMUP_TIMEOUTassertion withWORKERMAN_CACHE_WARMUP_TIMEOUTandgetCacheWarmupTimeouttestCacheWarmupTimeoutDefaultsTo30structural testTask 4: Verify
vendor/bin/phpunitvendor/bin/phpstan analysevendor/bin/php-cs-fixer fix --dry-runReferences
src/Runner.php—CACHE_WARMUP_TIMEOUTconstant and fork/timeout logicsrc/Runner.php:120-127— existinggetCacheDir()pattern with$_SERVERoverride