Module: RuboCop::Daemon

Defined in:
lib/rubocop/daemon.rb,
lib/rubocop/daemon/cli.rb,
lib/rubocop/daemon/cache.rb,
lib/rubocop/daemon/errors.rb,
lib/rubocop/daemon/helper.rb,
lib/rubocop/daemon/server.rb,
lib/rubocop/daemon/version.rb,
lib/rubocop/daemon/socket_reader.rb,
lib/rubocop/daemon/client_command.rb,
lib/rubocop/daemon/server_command.rb,
lib/rubocop/daemon/client_command/base.rb,
lib/rubocop/daemon/client_command/exec.rb,
lib/rubocop/daemon/client_command/stop.rb,
lib/rubocop/daemon/server_command/base.rb,
lib/rubocop/daemon/server_command/exec.rb,
lib/rubocop/daemon/server_command/stop.rb,
lib/rubocop/daemon/client_command/start.rb,
lib/rubocop/daemon/client_command/status.rb,
lib/rubocop/daemon/client_command/restart.rb

Defined Under Namespace

Modules: ClientCommand, Helper, ServerCommand Classes: CLI, Cache, GemfileNotFound, InvalidTokenError, Server, ServerStopRequest, SocketReader, UnknownClientCommandError, UnknownServerCommandError

Constant Summary collapse

TIMEOUT =
20
VERSION =
'0.3.1'.freeze

Class Method Summary collapse

Class Method Details

.running?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rubocop/daemon.rb', line 17

def self.running?
  Cache.dir.exist? && Cache.pid_path.file? && Cache.pid_running?
end

.wait_for_running_status!(expected) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/rubocop/daemon.rb', line 21

def self.wait_for_running_status!(expected)
  start_time = Time.now
  while Daemon.running? != expected
    sleep 0.1
    next unless Time.now - start_time > TIMEOUT

    warn "running? was not #{expected} after #{TIMEOUT} seconds!"
    exit 1
  end
end