<commit_before>require 'daemons'

module ZSS
  class Runner

    def self.run(proc_name)
      proc_name = proc_name.to_s
      pid_path = log_path = './log'

      FileUtils.mkdir_p pid_path
      FileUtils.mkdir_p log_path

      daemon_opts = {
        multiple:   true,
        dir_mode:   :normal,
        dir:        pid_path,
        log_output: true,
        stop_proc:  lambda do
          puts "stop #{proc_name} daemon..."
          $stop_requested = true
        end
      }

      puts "Starting #{proc_name}:\n\tPID: #{pid_path}\n\tLOGS: #{log_path}"

      Daemons.run_proc proc_name, daemon_opts do
        daemon = ZSS::ServiceRegister.get_service

        puts "Started #{proc_name} daemon..."
        daemon.run

        puts "Stoping #{proc_name} daemon"
        exit 0
      end
    end
  end
end<commit_msg>Adds possibility for multiple services<commit_after>require 'daemons'

module ZSS
  class Runner

    def self.run(proc_name)
      proc_name = proc_name.to_s
      pid_path = log_path = './log'

      FileUtils.mkdir_p pid_path
      FileUtils.mkdir_p log_path

      daemon_opts = {
        multiple:   true,
        dir_mode:   :normal,
        dir:        pid_path,
        log_output: true,
        stop_proc:  lambda do
          puts "stop #{proc_name} daemon..."
          $stop_requested = true
        end
      }

      puts "Starting #{proc_name}:\n\tPID: #{pid_path}\n\tLOGS: #{log_path}"

      Daemons.run_proc proc_name, daemon_opts do
        daemon = if ZSS::ServiceRegister.respond_to :get_services
          daemons = ZSS::ServiceRegister.get_services
          daemons.find { |daemon| daemon.sid == proc_name }
        else
          ZSS::ServiceRegister.get_service
        end

        puts "Started #{proc_name} daemon..."
        daemon.run

        puts "Stoping #{proc_name} daemon"
        exit 0
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09250398724082935, 'fraction_numerical': 0.001063264221158958, 'mean_word_length': 1.9684542586750788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '760614', 'n_tokens_mistral': 638, 'n_tokens_neox': 621, 'n_words': 138}