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)
| 21 | // It stops the service if it already exist in the manager and is running |
| 22 | // It then starts the newly added service |
| 23 | func (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 |
| 38 | func (m *AppManager) Remove(name string) { |