Start 启动服务
()
| 35 | |
| 36 | // Start 启动服务 |
| 37 | func (this *ServiceManager) Start() error { |
| 38 | if os.Getgid() != 0 { |
| 39 | return errors.New("only root users can start the service") |
| 40 | } |
| 41 | |
| 42 | if files.NewFile(systemdServiceFile).Exists() { |
| 43 | systemd, err := executils.LookPath("systemctl") |
| 44 | if err != nil { |
| 45 | return err |
| 46 | } |
| 47 | |
| 48 | return exec.Command(systemd, "start", teaconst.SystemdServiceName+".service").Start() |
| 49 | } |
| 50 | return exec.Command("service", teaconst.ProcessName, "start").Start() |
| 51 | } |
| 52 | |
| 53 | // Uninstall 删除服务 |
| 54 | func (this *ServiceManager) Uninstall() error { |