<commit_before>require 'miq_apache'
module WebServerWorkerMixin
  extend ActiveSupport::Concern

  included do
    class << self
      attr_accessor :registered_ports
    end

    def self.rails_server_command_line
      @rails_server_command_line ||= begin
        "#{self.nice_prefix} #{Rails.root.join("bin", "rails")} server".freeze
      end
    end

    def self.build_command_line(*params)
      params = params.first || {}

      defaults = {
        :port         => 3000,
        :binding      => "127.0.0.1",
        :environment  => Rails.env.to_s,
        :config       => Rails.root.join("config.ru")
      }

      params = defaults.merge(params)
      params[:pid]  = self.thin_pid_file(params[:port])

      # Usage: rails server [mongrel, thin, etc] [options]
      #      -p, --port=port                  Runs Rails on the specified port.
      #                                       Default: 3000
      #      -b, --binding=ip                 Binds Rails to the specified ip.
      #                                       Default: 0.0.0.0
      #      -c, --config=file                Use custom rackup configuration file
      #      -d, --daemon                     Make server run as a Daemon.
      #      -u, --debugger                   Enable ruby-debugging for the server.
      #      -e, --environment=name           Specifies the environment to run this server under (test/development/production).
      #                                       Default: development
      #      -P, --pid=pid                    Specifies the PID file.
      #                                       Default: tmp/pids/server.pid
      #
      #      -h, --help                       Show this help message.
      #
      cl = self.rails_server_command_line.dup

      params.each { |k, v| cl << " --#{k} \"#{v}\"" unless v.blank? }
      return cl
    end

    def self.all_ports_in_use
      self.server_scope.all.collect { |w| w.port unless w.is_stopped? && !MiqProcess.is_worker?(w.pid)}.compact
    end<commit_msg>Make 127.0.0.1 a constant with a getter method.<commit_after>require 'miq_apache'
module WebServerWorkerMixin
  extend ActiveSupport::Concern

  BINDING_ADDRESS = "127.0.0.1"

  included do
    class << self
      attr_accessor :registered_ports
    end

    def self.binding_address
      BINDING_ADDRESS
    end

    def self.rails_server_command_line
      @rails_server_command_line ||= begin
        "#{self.nice_prefix} #{Rails.root.join("bin", "rails")} server".freeze
      end
    end

    def self.build_command_line(*params)
      params = params.first || {}

      defaults = {
        :port         => 3000,
        :binding      => binding_address,
        :environment  => Rails.env.to_s,
        :config       => Rails.root.join("config.ru")
      }

      params = defaults.merge(params)
      params[:pid]  = self.thin_pid_file(params[:port])

      # Usage: rails server [mongrel, thin, etc] [options]
      #      -p, --port=port                  Runs Rails on the specified port.
      #                                       Default: 3000
      #      -b, --binding=ip                 Binds Rails to the specified ip.
      #                                       Default: 0.0.0.0
      #      -c, --config=file                Use custom rackup configuration file
      #      -d, --daemon                     Make server run as a Daemon.
      #      -u, --debugger                   Enable ruby-debugging for the server.
      #      -e, --environment=name           Specifies the environment to run this server under (test/development/production).
      #                                       Default: development
      #      -P, --pid=pid                    Specifies the PID file.
      #                                       Default: tmp/pids/server.pid
      #
      #      -h, --help                       Show this help message.
      #
      cl = self.rails_server_command_line.dup

      params.each { |k, v| cl << " --#{k} \"#{v}\"" unless v.blank? }
      return cl
    end

    def self.all_ports_in_use
      self.server_scope.all.collect { |w| w.port unless w.is_stopped? && !MiqProcess.is_worker?(w.pid)}.compact
    end
{'fraction_non_alphanumeric': 0.10541378487956117, 'fraction_numerical': 0.01001669449081803, 'mean_word_length': 1.4327146171693736, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5520322', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1172, 'n_words': 288}