Class: RuboCop::Server::ClientCommand::Start Private

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/server/client_command/start.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class is a client command to start server process.

API:

  • private

Instance Method Summary collapse

Methods inherited from Base

args_config_file_path

Constructor Details

#initialize(detach: true) ⇒ Start

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Start.

API:

  • private



18
19
20
21
# File 'lib/rubocop/server/client_command/start.rb', line 18

def initialize(detach: true)
  @detach = detach
  super()
end

Instance Method Details

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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

    write_version_file

    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