Class: RuboCop::Daemon::ClientCommand::Start

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

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from RuboCop::Daemon::ClientCommand::Base

Instance Method Details

#runObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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