Start browser on server start (#1832)

* Start browser on server start
* Add config option for opening browser
This commit is contained in:
kermieisinthehouse
2021-10-28 16:19:23 -07:00
committed by GitHub
parent 29b14ab4fc
commit 87036a07bc
24 changed files with 356 additions and 2 deletions

View File

@@ -4,9 +4,12 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"runtime"
"runtime/pprof"
"strings"
"sync"
"time"
@@ -391,6 +394,34 @@ func (s *singleton) Migrate(ctx context.Context, input models.MigrateInput) erro
return nil
}
func (s *singleton) IsDesktop() bool {
// check if running under root
if os.Getuid() == 0 {
return false
}
// check if started by init, e.g. stash is a *nix systemd service / MacOS launchd service
if os.Getppid() == 1 {
return false
}
if IsServerDockerized() {
return false
}
return true
}
func IsServerDockerized() bool {
if runtime.GOOS == "linux" {
_, dockerEnvErr := os.Stat("/.dockerenv")
cgroups, _ := ioutil.ReadFile("/proc/self/cgroup")
if os.IsExist(dockerEnvErr) || strings.Contains(string(cgroups), "docker") {
return true
}
}
return false
}
func (s *singleton) GetSystemStatus() *models.SystemStatus {
status := models.SystemStatusEnumOk
dbSchema := int(database.Version())