class RuboCop::Daemon::ClientCommand::Start

Public Instance Methods

run() click to toggle source
# File lib/rubocop/daemon/client_command/start.rb, line 7
def run
  if Daemon.running?
    warn 'rubocop-daemon: server is already running.'
    return
  end

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

    parser.parse(@argv)
    Server.new(@options.fetch(:no_daemon, false)).start(@options.fetch(:port, 0))
  end
end

Private Instance Methods

parser() click to toggle source
# File lib/rubocop/daemon/client_command/start.rb, line 28
def parser
  @parser ||= CLI.new_parser do |p|
    p.banner = 'usage: rubocop-daemon start [options]'

    p.on('-p', '--port [PORT]') { |v| @options[:port] = v }
    p.on('--no-daemon', 'Starts server in foreground with debug information') { @options[:no_daemon] = true }
  end
end