def run_custom_server_command!
      pid = nil
      stopped = false
      command_thread = Thread.new do
        pid = Process.spawn(server_command)
        logger.info "Started command: #{server_command} (pid: #{pid})"

        Process.wait pid
        pid = nil
        raise Interrupt, "Server command exit unexpectedly" unless stopped
      end

      command_thread.abort_on_exception = true

      at_stop do
        stopped = true
        next if pid.nil?

        Process.kill("SIGTERM", pid)

        logger.info "Wait till process #{pid} stop..."

        tick = 0

        loop do
          tick += 0.2
          break if tick > WAIT_PROCESS

          if pid.nil?
            logger.info "Process #{pid} stopped."
            break
          end
        end
      end
    end
def run_custom_server_command!
      pid = nil
      stopped = false
      command_thread = Thread.new do
        pid = Process.spawn(server_command)
        logger.info "Started command: #{server_command} (pid: #{pid})"

        Process.wait pid
        pid = nil
        raise Interrupt, "Server command exit unexpectedly" unless stopped
      end

      command_thread.abort_on_exception = true

      at_stop do
        stopped = true
        next if pid.nil?

        Process.kill("SIGTERM", pid)

        logger.info "Wait till process #{pid} stop..."

        tick = 0

        loop do
          tick += 0.2
          break if tick > WAIT_PROCESS

          if pid.nil?
            logger.info "Process #{pid} stopped."
            break
          end
        end
      end
    end
rubocop: disable Metrics/MethodLength, Metrics/AbcSize