feat(config): check pid for container startup (#1589)

fix(config): check pid for container startup
This commit is contained in:
Kyle Sanderson 2024-07-03 12:43:13 -07:00 committed by GitHub
parent 2881314ad4
commit 4f0e2d82b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -116,6 +116,11 @@ func (c *AppConfig) writeConfig(configPath string, configFile string) error {
// if this file exists then the viewer is running // if this file exists then the viewer is running
// from inside a lxc container so return true // from inside a lxc container so return true
host = "0.0.0.0" host = "0.0.0.0"
} else if os.Getpid() == 1 {
// if we're running as pid 1, we're honoured.
// but there's a good chance this is an isolated namespace
// or a container.
host = "0.0.0.0"
} else if pd, _ := os.Open("/proc/1/cgroup"); pd != nil { } else if pd, _ := os.Open("/proc/1/cgroup"); pd != nil {
defer pd.Close() defer pd.Close()
b := make([]byte, 4096) b := make([]byte, 4096)