Manage a worker pool
← All configuration scenariosYou want two application processes and a way to replace workers while the service is running. Enable a private management socket alongside a fixed worker count.
Start two workers
Save this as pool.json in the application root. Use a distinct socket name if you run multiple servers under the same account.
{
"listen": { "port": 9000 },
"workers": {
"count": 2,
"rotation": { "max_concurrent": 1, "drain_timeout_seconds": 30 }
},
"control": { "socket": "@runtime/example-pool.sock" }
}php vendor/mini4work/webserver/examples/server.php pool.jsonInspect and replace workers
In a second terminal under the same account, query the supervisor. Status returns JSON including its state and uptime.
client=vendor/mini4work/webserver/examples/control.php
socket=@runtime/example-pool.sock
php "$client" "$socket" statusOn this example instance, request replacement. The control client prints Accepted when the supervisor accepts the command. Check the server log for worker turnover and send another request after replacement.
php "$client" "$socket" restart-workers
curl -i http://127.0.0.1:9000/helloExpect HTTP 200 and a worker_pid from the serving pool. The rotation limit permits one replacement at a time. Draining gives admitted work up to 30 seconds to finish. See worker lifecycle settings for automatic request, age and memory triggers.