Sha256: 7d142066ebd7ca2f816d2d5dce45e99b5996b4cb4c90b70226300226b2cc80e3

Contents?: true

Size: 1.18 KB

Versions: 149

Compression:

Stored size: 1.18 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 initialize(detach: true)
          @detach = detach
          super()
        end

        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, detach: @detach)
          end
        end
      end
    end
  end
end

Version data entries

149 entries across 148 versions & 17 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/server/client_command/start.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/server/client_command/start.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rubocop-1.64.1/lib/rubocop/server/client_command/start.rb
rubocop-1.64.1 lib/rubocop/server/client_command/start.rb
rubocop-1.63.4 lib/rubocop/server/client_command/start.rb
rubocop-1.63.3 lib/rubocop/server/client_command/start.rb
rubocop-1.63.2 lib/rubocop/server/client_command/start.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/server/client_command/start.rb
rubocop-1.63.1 lib/rubocop/server/client_command/start.rb
rubocop-1.63.0 lib/rubocop/server/client_command/start.rb
bison-0.1.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.62.1/lib/rubocop/server/client_command/start.rb
rubocop-1.62.1 lib/rubocop/server/client_command/start.rb
rubocop-1.62.0 lib/rubocop/server/client_command/start.rb
rubocop-1.61.0 lib/rubocop/server/client_command/start.rb
mlh-rubocop-config-1.0.3 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.2/lib/rubocop/server/client_command/start.rb
rubocop-1.60.2 lib/rubocop/server/client_command/start.rb
study_line-0.2.7 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/server/client_command/start.rb
study_line-0.2.6 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/server/client_command/start.rb
study_line-0.2.5 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/server/client_command/start.rb
study_line-0.2.4 vendor/bundle/ruby/3.2.0/gems/rubocop-1.60.0/lib/rubocop/server/client_command/start.rb