Server control socket

Inspect server status, replace workers and stop the service through a private Unix socket.

Management socket

Since 1.9.0, control.socket defaults to "auto". Each launch creates a private socket with a random address. An explicit path provides a stable link. Set the value to null to disable control.

To give the socket a fixed name in the service account’s private runtime directory, save this profile as m4w.json.

JSON
{
  "listen": { "port": 9000 },
  "control": { "socket": "@runtime/mini4work.sock" }
}
Shell
php vendor/mini4work/webserver/examples/server.php m4w.json

In another terminal under the same account, inspect the running server.

Shell
vendor/bin/m4w --socket @runtime/mini4work.sock server:status

For a custom path, use a directory owned by the service account with mode 0700. The socket itself has mode 0600.

Run the CLI as the service account in the project directory. Startup and the CLI discover the nearest project and prefer m4w.json over m4w.jsonc. If multiple instances match, select a socket from the list with --socket.

server:status

Shell
vendor/bin/m4w server:status
vendor/bin/m4w --config m4w.json server:status --format json

Status includes both process IDs, uptime, state, log level, workers and queues. The CLI prints key/value lines by default. Use --format json in scripts or --format prometheus for metrics.

server:workers

Worker snapshots show availability, draining and completed requests. Check sampled_at for freshness. TCP counts completions in batches of 64. RSS is reported when memory-based rotation is enabled.

Shell
vendor/bin/m4w server:workers --format json

server:queues

TCP counts connections waiting for a worker. HTTP/3 counts queued requests and bytes. Check the oldest wait and the limit for each pool separately.

Shell
vendor/bin/m4w server:queues
vendor/bin/m4w server:queues --format prometheus

server:set-log-level

Change the threshold at runtime for current and replacement workers. Check log_level in the status report. A full restart restores the value from m4w.json.

Shell
vendor/bin/m4w server:set-log-level debug
vendor/bin/m4w server:status
vendor/bin/m4w server:set-log-level info
Logging

server:restart-workers

Shell
vendor/bin/m4w server:restart-workers

On 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.

Replacement workers use the current configuration. To change the pool size or other settings, edit m4w.json and start the server again with that file after stopping it.

server:stop

This command stops the entire service. The supervisor gives workers time to finish requests already in progress.

Shell
vendor/bin/m4w server:stop