class RuboCop::Server::ClientCommand::Start

This class is a client command to start server process. @api private

Public Class Methods

new(detach: true) click to toggle source
Calls superclass method
# File lib/rubocop/server/client_command/start.rb, line 18
def initialize(detach: true)
  @detach = detach
  super()
end

Public Instance Methods

run() click to toggle source
# File lib/rubocop/server/client_command/start.rb, line 23
def run
  if Server.running?
    warn "RuboCop server (#{Cache.pid_path.read}) is already running."
    return
  end

  Cache.acquire_lock do |locked|
    unless locked
      # Another process is already starting server,
      # so wait for it to be ready.
      Server.wait_for_running_status!(true)
      exit 0
    end

    Cache.write_version_file(Cache.restart_key)

    host = ENV.fetch('RUBOCOP_SERVER_HOST', '127.0.0.1')
    port = ENV.fetch('RUBOCOP_SERVER_PORT', 0)

    Server::Core.new.start(host, port, detach: @detach)
  end
end