jobec / powershell-prom-client

Prometheus instrumentation library for Powershell applications
BSD 2-Clause "Simplified" License
29 stars 10 forks source link

Setting up an exporter using a Job will fail #9

Open DennisL68 opened 12 months ago

DennisL68 commented 12 months ago

When using a job in PowerShell Windows 5,1 for running the Exporter, the job will fail with

Exception setting "TreatControlCAsInput":  "The handle is invalid.
"
At C:\Program Files\WindowsPowerShell\Modules\PromethuesExporter\0.1.0\PrometheusExporter.psm1:117 char:9
+        [Console]::TreatControlCAsInput = $True
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo           :  NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId  :  ExceptionsWhenSetting

as a job has no input handler.

A switch, -Interactive, might be an appropriate change to use when Ctrl-C is a viable input.

Or better yet, don't look for Ctrl-C at all, the script will still abort when breaking...