-
Notifications
You must be signed in to change notification settings - Fork 21
/
service_posix.go
64 lines (59 loc) · 1.43 KB
/
service_posix.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !windows
package winsvc
import (
"fmt"
"os"
"path/filepath"
)
func GetAppPath() (string, error) {
prog := os.Args[0]
p, err := filepath.Abs(prog)
if err != nil {
return "", err
}
fi, err := os.Stat(p)
if err == nil {
if !fi.Mode().IsDir() {
return p, nil
}
err = fmt.Errorf("winsvc.GetAppPath: %s is directory", p)
}
if filepath.Ext(p) == "" {
p += ".exe"
fi, err := os.Stat(p)
if err == nil {
if !fi.Mode().IsDir() {
return p, nil
}
err = fmt.Errorf("winsvc.GetAppPath: %s is directory", p)
}
}
return "", err
}
func InServiceMode() bool {
panic("winsvc: only support windows!")
}
func IsAnInteractiveSession() bool {
panic("winsvc: only support windows!")
}
func InstallService(appPath, name, desc string, params ...string) error {
panic("winsvc: only support windows!")
}
func RemoveService(name string) error {
panic("winsvc: only support windows!")
}
func RunAsService(name string, start, stop func(), isDebug bool) (err error) {
panic("winsvc: only support windows!")
}
func StartService(name string) error {
panic("winsvc: only support windows!")
}
func StopService(name string) error {
panic("winsvc: only support windows!")
}
func QueryService(name string) (status string, err error) {
panic("winsvc: only support windows!")
}