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

Method Install

internal/utils/service_windows.go:17–40  ·  view source on GitHub ↗

安装服务

(exePath string, args []string)

Source from the content-addressed store, hash-verified

15
16// 安装服务
17func (this *ServiceManager) Install(exePath string, args []string) error {
18 m, err := mgr.Connect()
19 if err != nil {
20 return fmt.Errorf("connecting: %w please 'Run as administrator' again", err)
21 }
22 defer m.Disconnect()
23 s, err := m.OpenService(this.Name)
24 if err == nil {
25 s.Close()
26 return fmt.Errorf("service %s already exists", this.Name)
27 }
28
29 s, err = m.CreateService(this.Name, exePath, mgr.Config{
30 DisplayName: this.Name,
31 Description: this.Description,
32 StartType: windows.SERVICE_AUTO_START,
33 }, args...)
34 if err != nil {
35 return fmt.Errorf("creating: %w", err)
36 }
37 defer s.Close()
38
39 return nil
40}
41
42// 启动服务
43func (this *ServiceManager) Start() error {

Callers

nothing calls this directly

Calls 2

CloseMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected