MCPcopy
hub / github.com/cloudflare/cloudflared / Add

Method Add

overwatch/app_manager.go:23–35  ·  view source on GitHub ↗

Add takes in a new service to manage. It stops the service if it already exist in the manager and is running It then starts the newly added service

(service Service)

Source from the content-addressed store, hash-verified

21// It stops the service if it already exist in the manager and is running
22// It then starts the newly added service
23func (m *AppManager) Add(service Service) {
24 // check for existing service
25 if currentService, ok := m.services[service.Name()]; ok {
26 if currentService.Hash() == service.Hash() {
27 return // the exact same service, no changes, so move along
28 }
29 currentService.Shutdown() //shutdown the listener since a new one is starting
30 }
31 m.services[service.Name()] = service
32
33 //start the service!
34 go m.serviceRun(service)
35}
36
37// Remove shutdowns the service by name and removes it from its current management list
38func (m *AppManager) Remove(name string) {

Callers 3

TestManagerAddAndRemoveFunction · 0.95
TestManagerDuplicateFunction · 0.95
TestManagerErrorChannelFunction · 0.95

Calls 4

serviceRunMethod · 0.95
NameMethod · 0.65
HashMethod · 0.65
ShutdownMethod · 0.65

Tested by 3

TestManagerAddAndRemoveFunction · 0.76
TestManagerDuplicateFunction · 0.76
TestManagerErrorChannelFunction · 0.76