🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
fix(insights): check if running in a container
Deluan906ac635c296
diff --git a/Dockerfile b/Dockerfileindex 7e9a0c4c0..7c966dc1c 100644--- a/Dockerfile+++ b/Dockerfile@@ -134,6 +134,7 @@ ENV ND_MUSICFOLDER=/musicENV ND_DATAFOLDER=/dataENV ND_PORT=4533ENV GODEBUG="asyncpreemptoff=1"+RUN touch /.nddockerenvEXPOSE ${ND_PORT}HEALTHCHECK CMD wget -O- http://localhost:${ND_PORT}/ping || exit 1diff --git a/consts/consts.go b/consts/consts.goindex fa57562a1..eb0c34a33 100644--- a/consts/consts.go+++ b/consts/consts.go@@ -3,6 +3,7 @@ package constsimport ("crypto/md5""fmt"+ "os""path/filepath""strings""time"@@ -134,3 +135,11 @@ var (ServerStart = time.Now())++var InContainer = func() bool {+ // Check if the /.nddockerenv file exists+ if _, err := os.Stat("/.nddockerenv"); err == nil {+ return true+ }+ return false+}()diff --git a/core/metrics/insights.go b/core/metrics/insights.goindex 8a4b1a6d4..27d154f1e 100644--- a/core/metrics/insights.go+++ b/core/metrics/insights.go@@ -151,6 +151,7 @@ var staticData = sync.OnceValue(func() insights.Data {// Build infodata.Build.Settings, data.Build.GoVersion = buildInfo()+ data.OS.Containerized = consts.InContainer// OS infodata.OS.Type = runtime.GOOSdiff --git a/core/metrics/insights/data.go b/core/metrics/insights/data.goindex 0cf7b0411..cf28c43a3 100644--- a/core/metrics/insights/data.go+++ b/core/metrics/insights/data.go@@ -10,11 +10,12 @@ type Data struct {GoVersion string `json:"goVersion"`} `json:"build"`OS struct {- Type string `json:"type"`- Distro string `json:"distro,omitempty"`- Version string `json:"version,omitempty"`- Arch string `json:"arch"`- NumCPU int `json:"numCPU"`+ Type string `json:"type"`+ Distro string `json:"distro,omitempty"`+ Version string `json:"version,omitempty"`+ Containerized bool `json:"containerized"`+ Arch string `json:"arch"`+ NumCPU int `json:"numCPU"`} `json:"os"`Mem struct {Alloc uint64 `json:"alloc"`