Process Probe
Executes an external process (dotnet --info) and reports its success & duration. Useful to validate required tooling or a helper binary.
Full source
File: pwsh/tutorial/examples/16.4-Health-Process-Probe.ps1
<#
Process Probe Example
Demonstrates using a process probe to execute a lightweight external command.
#>
param(
[int]$Port = 5000,
[IPAddress]$IPAddress = [IPAddress]::Loopback
)
## 1. Logging
New-KrLogger | Add-KrSinkConsole | Register-KrLogger -Name 'console' -SetAsDefault
## 2. Server
New-KrServer -Name 'Health Process Probe'
## 3. Listener (port 5000)
Add-KrEndpoint -Port $Port -IPAddress $IPAddress
#
## 5. Enable configuration
Enable-KrConfiguration
## 6. Process probe - executes 'dotnet --info' (with timeout)
Add-KrHealthProcessProbe -Name 'DotNetInfo' -FilePath 'dotnet' -Arguments '--info' -Timeout '00:00:03' -Tags 'system', 'self'
## 7. Health endpoint
Add-KrHealthEndpoint -Pattern '/healthz' -DefaultTags 'self', 'system' -ProbeTimeout '00:00:05'
## 8. Start server
Start-KrServer
Step-by-step
- Register a process probe with
-Kind Process, specifying-FileNameand optional-Arguments. - Non-zero exit codes are recorded as
Unhealthy. - Duration is captured automatically in the result.
- Start the server and query
/healthz.
Try It
Invoke-RestMethod http://127.0.0.1:5003/healthz | ConvertTo-Json -Depth 4
Break it by using an invalid executable name; observe Unhealthy state.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Probe hangs | Long‑running process | Wrap with a script probe and enforce custom timeout logic |
| Permission denied | Execution policy / ACL | Run with appropriate permissions or adjust policy |
References
- New-KrLogger
- New-KrServer
- Add-KrEndpoint
- Enable-KrConfiguration
- Add-KrHealthProcessProbe
- Add-KrHealthEndpoint
- Start-KrServer
- New-KrProbeResult
Previous / Next
Previous: HTTP Probe Next: C# Probe