mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
fix(insights): check if running in a container
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
6bc4c0317f
commit
906ac635c2
4 changed files with 17 additions and 5 deletions
|
@ -134,6 +134,7 @@ ENV ND_MUSICFOLDER=/music
|
|||
ENV ND_DATAFOLDER=/data
|
||||
ENV ND_PORT=4533
|
||||
ENV GODEBUG="asyncpreemptoff=1"
|
||||
RUN touch /.nddockerenv
|
||||
|
||||
EXPOSE ${ND_PORT}
|
||||
HEALTHCHECK CMD wget -O- http://localhost:${ND_PORT}/ping || exit 1
|
||||
|
|
|
@ -3,6 +3,7 @@ package consts
|
|||
import (
|
||||
"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
|
||||
}()
|
||||
|
|
|
@ -151,6 +151,7 @@ var staticData = sync.OnceValue(func() insights.Data {
|
|||
|
||||
// Build info
|
||||
data.Build.Settings, data.Build.GoVersion = buildInfo()
|
||||
data.OS.Containerized = consts.InContainer
|
||||
|
||||
// OS info
|
||||
data.OS.Type = runtime.GOOS
|
||||
|
|
|
@ -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"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue