gitee.com/quant1x/gox@v1.21.2/daemon/daemon_linux.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by 3 // license that can be found in the LICENSE file. 4 5 // Package daemon linux version 6 package daemon 7 8 import ( 9 "os" 10 ) 11 12 // Get the daemon properly 13 func newDaemon(name, description string, kind Kind, dependencies []string) (Daemon, error) { 14 // newer subsystem must be checked first 15 if _, err := os.Stat("/run/systemd/system"); err == nil { 16 return &systemDRecord{name, description, kind, dependencies}, nil 17 } 18 if _, err := os.Stat("/sbin/initctl"); err == nil { 19 return &upstartRecord{name, description, kind, dependencies}, nil 20 } 21 return &systemVRecord{name, description, kind, dependencies}, nil 22 } 23 24 // Get executable path 25 func execPath() (string, error) { 26 return os.Readlink("/proc/self/exe") 27 }