def renew!
      return if renew?

      @renew = Thread.new do
        ## Wakeup every TTL/2 seconds and renew the session
        loop do
          sleep ttl / 2

          begin
            logger.debug(" - Renewing Consul session #{id}")
            Diplomat::Session.renew(id)

          rescue Faraday::ResourceNotFound
            logger.warn("Consul session #{id} has expired!")

            init
          rescue StandardError => e
            ## Keep the thread from exiting
            logger.error(e)
          end
        end
      end

      self
    end
def renew!
      return if renew?

      @renew = Thread.new do
        ## Wakeup every TTL/2 seconds and renew the session
        loop do
          sleep ttl / 2

          begin
            logger.debug(" - Renewing Consul session #{id}")
            Diplomat::Session.renew(id)

          rescue Faraday::ResourceNotFound
            logger.warn("Consul session #{id} has expired!")

            init
          rescue StandardError => e
            ## Keep the thread from exiting
            logger.error(e)
          end
        end
      end

      self
    end
Create a thread to periodically renew the lock session