<commit_before>module EffectiveTestBot
  class Command
    def initialize(args = {})
      @options = {
        :pid_dir => "#{Rails.root}/tmp/pids",
        :pid_file => "#{Rails.root}/tmp/pids/effective_test_bot.pid"
      }
    end

    def start
      Dir.mkdir(@options[:pid_dir]) unless File.exists?(@options[:pid_dir])

      # Also check how this process was called.  Don't run on delayed_job kind athing
      puts "EffectiveTestBot started with parent process #{Process.argv0}"

      # Only run the EffectiveTestBot if we are running as a server
      if ['rails', 'ruby_executable_hooks'].none? { |cmd| Process.argv0.end_with?(cmd) }
        puts 'EffectiveTestBot skipping run.  Exitting.'
        exit 1
      end

      file = File.new(@options[:pid_file], 'w')
      mutex = file.flock(File::LOCK_EX|File::LOCK_NB)

      if mutex == false
        puts "EffectiveTestBot already run.  Exitting."
        exit 1
      end

      at_exit do
        (File.delete(@options[:pid_file]) rescue true)
      end

      begin
        EffectiveTestBot::Worker.new().start
      rescue => e
        Rails.logger.fatal e
        STDERR.puts e.message
        exit 1
      end
    end
  end
end<commit_msg>add unicorn to allowed processes<commit_after>module EffectiveTestBot
  class Command
    def initialize(args = {})
      @options = {
        :pid_dir => "#{Rails.root}/tmp/pids",
        :pid_file => "#{Rails.root}/tmp/pids/effective_test_bot.pid"
      }
    end

    def start
      Dir.mkdir(@options[:pid_dir]) unless File.exists?(@options[:pid_dir])

      # Also check how this process was called.  Don't run on delayed_job kind athing
      puts "EffectiveTestBot started with parent process #{Process.argv0}"

      # Only run the EffectiveTestBot if we are running as a server
      if ['rails', 'ruby_executable_hooks', 'unicorn'].none? { |cmd| Process.argv0.end_with?(cmd) }
        puts 'EffectiveTestBot skipping run.  Exitting.'
        exit 1
      end

      file = File.new(@options[:pid_file], 'w')
      mutex = file.flock(File::LOCK_EX|File::LOCK_NB)

      if mutex == false
        puts "EffectiveTestBot already run.  Exitting."
        exit 1
      end

      at_exit do
        (File.delete(@options[:pid_file]) rescue true)
      end

      begin
        EffectiveTestBot::Worker.new().start
      rescue => e
        Rails.logger.fatal e
        STDERR.puts e.message
        exit 1
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10825163398692811, 'fraction_numerical': 0.004084967320261438, 'mean_word_length': 2.382596685082873, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2343066', 'n_tokens_mistral': 785, 'n_tokens_neox': 755, 'n_words': 198}