This commit is contained in:
Alliballibaba
2026-02-20 19:16:38 +01:00
parent 6f854867b9
commit 89c6746e67
2 changed files with 5 additions and 9 deletions

View File

@@ -159,7 +159,7 @@ func (f *FrankenPHPApp) Start() error {
frankenphp.WithWorkerMaxFailures(w.MaxConsecutiveFailures),
frankenphp.WithWorkerMaxThreads(w.MaxThreads),
frankenphp.WithWorkerRequestOptions(w.requestOptions...),
frankenphp.WithWorkerArgs(w.nonHttp, w.Args), // TODO: add support for worker args in the Caddyfile
frankenphp.WithWorkerArgs(w.nonHttp, w.Args),
)
f.opts = append(f.opts, frankenphp.WithWorkers(w.Name, repl.ReplaceKnown(w.FileName, ""), w.Num, w.options...))

View File

@@ -160,11 +160,9 @@ func TestWorkerHasOSEnvironmentVariableInSERVER(t *testing.T) {
}
func TestWorkerWithArgs(t *testing.T) {
var buf fmt.Stringer
logger, buf := newTestLogger(t)
cwd, _ := os.Getwd()
testDataDir := cwd + "/testdata/"
workerFile := testDataDir + "worker-with-args.php"
workerFile := cwd + "/testdata/worker-with-args.php"
require.NoError(
t,
@@ -174,20 +172,18 @@ func TestWorkerWithArgs(t *testing.T) {
"non-http-worker",
workerFile,
1,
frankenphp.WithWorkerArgs([]string{"arg1", "arg2", "arg3"}),
frankenphp.WithWorkerArgs(true, []string{"arg1", "arg2", "arg3"}),
),
),
)
t.Cleanup(frankenphp.Shutdown)
require.Eventually(t, func() bool {
logOutput := buf.String()
return strings.Contains(logOutput, "just executing a script")
return strings.Contains(buf.String(), "just executing a script")
}, 5*time.Second, 30*time.Millisecond, "Worker did not execute")
require.Eventually(t, func() bool {
logOutput := buf.String()
expectedArgv := strings.Join([]string{workerFile, "arg1", "arg2", "arg3"}, ",")
return strings.Contains(logOutput, "argc is 4") && strings.Contains(logOutput, expectedArgv)
return strings.Contains(buf.String(), "argc is 4") && strings.Contains(buf.String(), expectedArgv)
}, 5*time.Second, 30*time.Millisecond, "Worker did not receive the expected arguments")
}