forked from takama/daemon
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdaemon_linux.go
More file actions
32 lines (25 loc) · 722 Bytes
/
daemon_linux.go
File metadata and controls
32 lines (25 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2015 Igor Dolzhikov. All rights reserved.
// Use of this source code is governed by
// license that can be found in the LICENSE file.
// Package daemon linux version
package daemon
import (
"github.com/oliveagle/goos"
"os"
)
// Get the daemon properly
func newDaemon(name, description string) (Daemon, error) {
ID, _, _, _ := goos.GetOSVersion()
if ID == "ubuntu" {
// do ubuntu things
return &ubuntuSysVRecord{name, description}, nil
}
if _, err := os.Stat("/run/systemd/system"); err == nil {
return &systemDRecord{name, description}, nil
}
return &systemVRecord{name, description}, nil
}
// Get executable path
func execPath() (string, error) {
return os.Readlink("/proc/self/exe")
}