Start starts the API by initializing the watcher and updater loops. This method calls Init, if it is desired to apply options after the API has been created, it should be done by calling Init before Start. This method must only be called once.
()
| 400 | // the API has been created, it should be done by calling Init before |
| 401 | // Start. This method must only be called once. |
| 402 | func (api *API) Start() { |
| 403 | api.Init() |
| 404 | |
| 405 | api.mu.Lock() |
| 406 | defer api.mu.Unlock() |
| 407 | if api.closed { |
| 408 | return |
| 409 | } |
| 410 | |
| 411 | if api.projectDiscovery && api.agentDirectory != "" { |
| 412 | api.discoverDone = make(chan struct{}) |
| 413 | |
| 414 | go api.discover() |
| 415 | } |
| 416 | |
| 417 | api.watcherDone = make(chan struct{}) |
| 418 | api.updaterDone = make(chan struct{}) |
| 419 | |
| 420 | go api.watcherLoop() |
| 421 | go api.updaterLoop() |
| 422 | } |
| 423 | |
| 424 | func (api *API) discover() { |
| 425 | defer close(api.discoverDone) |