MCPcopy Index your code
hub / github.com/php/frankenphp / ExampleServeHTTP_workers

Function ExampleServeHTTP_workers

worker_test.go:115–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113}
114
115func ExampleServeHTTP_workers() {
116 if err := frankenphp.Init(
117 frankenphp.WithWorkers("worker1", "worker1.php", 4,
118 frankenphp.WithWorkerEnv(map[string]string{"ENV1": "foo"}),
119 frankenphp.WithWorkerWatchMode([]string{}),
120 frankenphp.WithWorkerMaxFailures(0),
121 ),
122 frankenphp.WithWorkers("worker2", "worker2.php", 2,
123 frankenphp.WithWorkerEnv(map[string]string{"ENV2": "bar"}),
124 frankenphp.WithWorkerWatchMode([]string{}),
125 frankenphp.WithWorkerMaxFailures(0),
126 ),
127 ); err != nil {
128 panic(err)
129 }
130 defer frankenphp.Shutdown()
131
132 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
133 req, err := frankenphp.NewRequestWithContext(r, frankenphp.WithRequestDocumentRoot("/path/to/document/root", false))
134 if err != nil {
135 panic(err)
136 }
137
138 if err := frankenphp.ServeHTTP(w, req); err != nil {
139 panic(err)
140 }
141 })
142 log.Fatal(http.ListenAndServe(":8080", nil))
143}
144
145func TestWorkerHasOSEnvironmentVariableInSERVER(t *testing.T) {
146 runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) {

Callers

nothing calls this directly

Calls 9

InitFunction · 0.92
WithWorkersFunction · 0.92
WithWorkerEnvFunction · 0.92
WithWorkerWatchModeFunction · 0.92
WithWorkerMaxFailuresFunction · 0.92
ShutdownFunction · 0.92
NewRequestWithContextFunction · 0.92
WithRequestDocumentRootFunction · 0.92
ServeHTTPFunction · 0.92

Tested by

no test coverage detected