docs: def tune_in(self, start=True):
          '''
          Lock onto the publisher. This is the main event loop for the minion
          :rtype : None
          '''
          self._pre_tune()
  
          log.debug('Minion \'%s\' trying to tune in', self.opts['id'])
  
          if start:
              if self.opts.get('beacons_before_connect', False):
                  self.setup_beacons(before_connect=True)
              if self.opts.get('scheduler_before_connect', False):
                  self.setup_scheduler(before_connect=True)
              self.sync_connect_master()
          if self.connected:
              self._fire_master_minion_start()
              log.info('Minion is ready to receive requests!')
  
          # Make sure to gracefully handle SIGUSR1
          enable_sigusr1_handler()
  
          # Make sure to gracefully handle CTRL_LOGOFF_EVENT
          if HAS_WIN_FUNCTIONS:
              salt.utils.win_functions.enable_ctrl_logoff_handler()
  
          # On first startup execute a state run if configured to do so
          self._state_run()
  
          self.setup_beacons()
          self.setup_scheduler()
  
          # schedule the stuff that runs every interval
          ping_interval = self.opts.get('ping_interval', 0) * 60
          if ping_interval > 0 and self.connected:
              def ping_master():
                  try:
                      def ping_timeout_handler(*_):
                          if self.opts.get('auth_safemode', False):
                              log.error('** Master Ping failed. Attempting to restart minion**')
                              delay = self.opts.get('random_reauth_delay', 5)
                              log.info('delaying random_reauth_delay %ss', delay)
                              try:
                                  self.functions['service.restart'](service_name())
                              except KeyError:
                                  # Probably no init system (running in docker?)
                                  log.warning(
                                      'ping_interval reached without response '
                                      'from the master, but service.restart '
                                      'could not be run to restart the minion '
                                      'daemon. ping_interval requires that the '
                                      'minion is running under an init system.'
                                  )
  
                      self._fire_master('ping', 'minion_ping', sync=False, timeout_handler=ping_timeout_handler)
                  except Exception:
                      log.warning('Attempt to ping master failed.', exc_on_loglevel=logging.DEBUG)
              self.periodic_callbacks['ping'] = tornado.ioloop.PeriodicCallback(ping_master, ping_interval * 1000)
              self.periodic_callbacks['ping'].start()
  
          # add handler to subscriber
          if hasattr(self, 'pub_channel') and self.pub_channel is not None:
              self.pub_channel.on_recv(self._handle_payload)
          elif self.opts.get('master_type') != 'disable':
              log.error('No connection to master found. Scheduled jobs will not run.')
  
          if start:
              try:
                  self.io_loop.start()
                  if self.restart:
                      self.destroy()
              except (KeyboardInterrupt, RuntimeError):  # A RuntimeError can be re-raised by Tornado on shutdown
                  self.destroy()