Files
public/server/server_linux.go
xiexiaojun 2ace0bade5 new
new
2019-03-07 21:30:01 +08:00

33 lines
560 B
Go

package server
import (
"fmt"
"os/exec"
"strings"
)
type WindowsServiceTools struct {
i ServiceTools
}
func IsStart(name string) (st int, err error) {
f, _ := exec.Command("service", name, "status").Output()
st = NOTFIND
str := string(f)
a := strings.Split(str, "\n")
for _, v := range a {
if strings.Index(v, "Active:") > 0 {
fmt.Println("====info===:", v)
if strings.Index(v, "inactive") > 0 { //不活动的
st = Stopped
} else if strings.Index(v, "activating") > 0 { //活动的
st = Running
}
break
}
}
return
}