code: func (svc *Service) run() {
  
  	// Wait for dependencies to start.
  	for _, dep := range svc.dependencies {
  		log.Infof("Service %s waiting for %s to start", svc.name, dep.name)
  		select {
  		case started := <-dep.started:
  			dep.started <- started
  		case <-svc.shutdown:
  			goto done
  		}
  	}
  
  	for {
  		if svc.failures > 0 {
  			delay := time.Duration(svc.failures) * restartBackoff
  			if delay > restartBackoffMax {
  				delay = restartBackoffMax
  			}
  			log.Infof("Service %s has failed %d times - delaying %s before restart",
  				svc.name, svc.failures, delay)
  
  			select {
  			case <-time.After(delay):
  			case <-svc.shutdown:
  				goto done
  			}
  		}
  
  		svc.restarts++
  		svc.lastRestart = time.Now()
  		svc.runOnce()
  
  		select {
  		case <-time.After(restartDelay):
  		case <-svc.shutdown:
  			goto done
  		}
  	}
  done:
  	svc.done <- true
  }
docs: // run runs a service and restarts it upon termination, unless a shutdown
  // notification has been received.