123456789_123456789_123456789_123456789_123456789_

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

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
self, Base
Inherits: RuboCop::Server::ClientCommand::Base
Defined in: lib/rubocop/server/client_command/start.rb

Overview

This class is a client command to start server process.

Class Method Summary

Base - Inherited

Instance Method Summary

Base - Inherited

Constructor Details

.new(detach: true) ⇒ Start

[ GitHub ]

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

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

Instance Method Details

#run

[ GitHub ]

  
# 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

#write_version_file (private)

[ GitHub ]

  
# File 'lib/rubocop/server/client_command/start.rb', line 48

def write_version_file
  Cache.write_version_file(
    Cache.restart_key(
      args_config_file_path: self.class.args_config_file_path
    )
  )
end