run invokes a vserver. This is a long-lived Go routine that lasts for the duration of the vserver, reacting to configuration changes and healthcheck notifications.
()
| 471 | // duration of the vserver, reacting to configuration changes and healthcheck |
| 472 | // notifications. |
| 473 | func (v *vserver) run() { |
| 474 | statsTicker := time.NewTicker(v.engine.config.StatsInterval) |
| 475 | for { |
| 476 | select { |
| 477 | case <-v.quit: |
| 478 | // Shutdown active vservers, services and destinations. |
| 479 | // There is no race between this and new healthcheck |
| 480 | // notifications, since they are also handled via the |
| 481 | // same vserver go routine. |
| 482 | v.downAll() |
| 483 | statsTicker.Stop() |
| 484 | v.engine.hcManager.vcc <- vserverChecks{vserverName: v.config.Name} |
| 485 | v.unconfigureVIPs() |
| 486 | |
| 487 | // Return any firewall marks that were allocated to |
| 488 | // this vserver. |
| 489 | for _, fwm := range v.fwm { |
| 490 | v.engine.fwmAlloc.put(fwm) |
| 491 | } |
| 492 | |
| 493 | v.stopped <- true |
| 494 | return |
| 495 | |
| 496 | case o := <-v.overrideChan: |
| 497 | v.handleOverride(o) |
| 498 | v.engine.hcManager.vcc <- v.healthchecks() |
| 499 | |
| 500 | case config := <-v.update: |
| 501 | v.handleConfigUpdate(config) |
| 502 | v.engine.hcManager.vcc <- v.healthchecks() |
| 503 | |
| 504 | case n := <-v.notify: |
| 505 | v.handleCheckNotification(n) |
| 506 | |
| 507 | case <-statsTicker.C: |
| 508 | v.updateStats() |
| 509 | select { |
| 510 | case v.engine.vserverChan <- v.snapshot(): |
| 511 | default: |
| 512 | log.Warningf("%v: failed to send snapshot", v) |
| 513 | } |
| 514 | } |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | // stop tells a running vserver that it should quit. |
| 519 | func (v *vserver) stop() { |
nothing calls this directly
no test coverage detected