MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / Uninstall

Method Uninstall

internal/utils/service_linux.go:54–79  ·  view source on GitHub ↗

Uninstall 删除服务

()

Source from the content-addressed store, hash-verified

52
53// Uninstall 删除服务
54func (this *ServiceManager) Uninstall() error {
55 if os.Getgid() != 0 {
56 return errors.New("only root users can uninstall the service")
57 }
58
59 if files.NewFile(systemdServiceFile).Exists() {
60 systemd, err := executils.LookPath("systemctl")
61 if err != nil {
62 return err
63 }
64
65 // disable service
66 _ = executils.NewTimeoutCmd(10*time.Second, systemd, "disable", teaconst.SystemdServiceName+".service").Start()
67
68 // reload
69 _ = executils.NewTimeoutCmd(10*time.Second, systemd, "daemon-reload").Start()
70
71 return files.NewFile(systemdServiceFile).Delete()
72 }
73
74 f := files.NewFile(initServiceFile)
75 if f.Exists() {
76 return f.Delete()
77 }
78 return nil
79}
80
81// install init service
82func (this *ServiceManager) installInitService(exePath string, args []string) error {

Callers 2

setupSystemdMethod · 0.45
mainFunction · 0.45

Calls 2

StartMethod · 0.65
DeleteMethod · 0.65

Tested by

no test coverage detected