Serve Mode
One of the Runner’s available modes isserve mode.
The runner can be started in serve mode by setting the WMC_DEFAULT_MODE environment variable to serve,
or switched to this mode using the Runner’s switch endpoint.
This mode starts a local playback session that will continue to serve your configured services
until the runner is stopped or its mode is switched.
Serve Configuration
The serve session started by the Runner can be configured via the same mechanism as therun command
of the WireMock CLI - either via a values file or via environment variables.
Additionally, configuration can be provided at switch time via the HTTP request body.
All options available to the run CLI command are also available to the Runner’s serve mode.
When specifying an option in the "config" field of the HTTP switch request, remove the dash (-) prefix that would normally be used when provided on the command line.
For instance, the --profile option would become "profile" in the request body, like so:
.wiremock directory
in the current working directory of the container.
Manual Reload
Regardless of whether--watch is enabled, you can trigger an on-demand reload of every
service’s stub-mappings.yaml by sending an HTTP POST request to /v1/serve/reload on the Runner’s admin port.
This re-checks each service’s stub-mappings.yaml and applies any changes without restarting the Runner - the same
behavior --watch triggers automatically on a filesystem change.
request
reloaded, unchanged, or failed:
200 OK if every service reloaded successfully or was unchanged. If a service’s
stub-mappings.yaml couldn’t be read or failed to parse, that service’s outcome is failed with an error message,
and the overall response status is 500 Internal Server Error, while every other service in the response is still
updated:
Starting the Runner In Serve Mode
When starting the runner inserve mode you will need to publish the appropriate ports
for the services you are running along with the port you have configured for the Runner.
Here is a typical example on Linux or macOS when running the Runner on port 9999 and serving two services:
Extensions
The WireMock Runner’sserve mode can be customised in the same way as WireMock OSS.
More information on how to extend the WireMock Runner can be found here.
Telemetry
The WireMock Runner’sserve mode can be configured to export OpenTelemetry signals to a backend of your choice.
Configuration is done via environment variables, as specified by the OpenTelemetry specification.
For example, to emit logs to a backend that supports OTLP
at the endpoint https://my-telemetry-service:8080, set the following environment variables:
OTEL_LOGS_EXPORTER=otlp.OTEL_EXPORTER_OTLP_ENDPOINT=https://my-telemetry-service:8080.
OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, OTEL_LOGS_EXPORTER are:
otlp: OTLPconsole: Standard Outputnone: No automatically configured exporter.
OTEL_TRACES_EXPORTER,
OTEL_METRICS_EXPORTER, and OTEL_LOGS_EXPORTER, which are all set to none by default, rather than otlp.
These telemetry options also apply to the wiremock run command.