From ab80450b66469a582b4df63491a8163c931e124c Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Fri, 13 Feb 2026 11:11:10 +0300 Subject: [PATCH] Expose process PID in API and UI Include the process PID in the API info payload and surface it in the frontend. apiHandler now adds app.Info["pid"] = os.Getpid(); openapi.yaml documents the new pid property as an integer with an example; www/index.html is updated to show pid alongside version and config. This aids debugging and identifying the running process. --- internal/api/api.go | 1 + website/api/openapi.yaml | 1 + www/index.html | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/api/api.go b/internal/api/api.go index dfb65117..878bd6aa 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -238,6 +238,7 @@ var mu sync.Mutex func apiHandler(w http.ResponseWriter, r *http.Request) { mu.Lock() app.Info["host"] = r.Host + app.Info["pid"] = os.Getpid() mu.Unlock() ResponseJSON(w, app.Info) diff --git a/website/api/openapi.yaml b/website/api/openapi.yaml index b6110572..16611230 100644 --- a/website/api/openapi.yaml +++ b/website/api/openapi.yaml @@ -123,6 +123,7 @@ paths: properties: config_path: { type: string, example: "/config/go2rtc.yaml" } host: { type: string, example: "192.168.1.123:1984" } + pid: { type: integer, example: 12345 } rtsp: type: object properties: diff --git a/www/index.html b/www/index.html index 69126e6f..34ad2c9d 100644 --- a/www/index.html +++ b/www/index.html @@ -147,7 +147,12 @@ const url = new URL('api', location.href); fetch(url, {cache: 'no-cache'}).then(r => r.json()).then(data => { const info = document.querySelector('.info'); - info.innerText = `version: ${data.version} / config: ${data.config_path}`; + const parts = [ + `version: ${data.version}`, + `pid: ${data.pid}`, + `config: ${data.config_path}`, + ]; + info.innerText = parts.join(' / '); }); reload();