Sha256: 4b9f6a602bad5cdcbfa687a791b72f22b4d1cee80f8910ce310ae6ac1f56247c

Contents?: true

Size: 1.08 KB

Versions: 30

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

#
# This code is based on https://github.com/fohte/rubocop-daemon.
#
# Copyright (c) 2018 Hayato Kawai
#
# The MIT License (MIT)
#
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
#
module RuboCop
  module Server
    module ClientCommand
      # This class is a client command to start server process.
      # @api private
      class Start < Base
        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

            Cache.write_version_file(RuboCop::Version::STRING)

            host = ENV.fetch('RUBOCOP_SERVER_HOST', '127.0.0.1')
            port = ENV.fetch('RUBOCOP_SERVER_PORT', 0)

            Server::Core.new.start(host, port)
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 26 versions & 3 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/server/client_command/start.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/server/client_command/start.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/server/client_command/start.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.31.2/lib/rubocop/server/client_command/start.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.35.1/lib/rubocop/server/client_command/start.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/server/client_command/start.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.31.2/lib/rubocop/server/client_command/start.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.35.1/lib/rubocop/server/client_command/start.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/server/client_command/start.rb
rubocop-1.44.1 lib/rubocop/server/client_command/start.rb
rubocop-1.44.0 lib/rubocop/server/client_command/start.rb
rubocop-1.43.0 lib/rubocop/server/client_command/start.rb
rubocop-1.42.0 lib/rubocop/server/client_command/start.rb
rubocop-1.41.1 lib/rubocop/server/client_command/start.rb
rubocop-1.41.0 lib/rubocop/server/client_command/start.rb
rubocop-1.40.0 lib/rubocop/server/client_command/start.rb
rubocop-1.39.0 lib/rubocop/server/client_command/start.rb
rubocop-1.38.0 lib/rubocop/server/client_command/start.rb
rubocop-1.37.1 lib/rubocop/server/client_command/start.rb
rubocop-1.37.0 lib/rubocop/server/client_command/start.rb