<commit_before>require 'procodile/control_server'

module Procodile
  class Supervisor

    attr_reader :config
    attr_reader :processes

    # Create a new supervisor instance that will be monitoring the
    # processes that have been provided.
    def initialize(config)
      @config = config
      @processes = {}

      signal_handler = SignalHandler.new('TERM', 'USR1', 'USR2', 'INT', 'HUP')
      signal_handler.register('TERM') { stop }
      signal_handler.register('USR1') { restart }
      signal_handler.register('USR2') { status }
      signal_handler.register('HUP') { reload_config }
    end

    def start
      Procodile.log nil, "system", "#{@config.app_name} supervisor started with PID #{::Process.pid}"
      @config.processes.each do |name, process|
        start_instances(process.generate_instances)
      end

      Thread.new do
        socket = ControlServer.new(self)
        socket.listen
      end

      supervise
    end

    def stop
      return if @stopping
      @stopping = true<commit_msg>re-add a missing INT signal handler<commit_after>require 'procodile/control_server'

module Procodile
  class Supervisor

    attr_reader :config
    attr_reader :processes

    # Create a new supervisor instance that will be monitoring the
    # processes that have been provided.
    def initialize(config)
      @config = config
      @processes = {}

      signal_handler = SignalHandler.new('TERM', 'USR1', 'USR2', 'INT', 'HUP')
      signal_handler.register('TERM') { stop }
      signal_handler.register('INT') { stop }
      signal_handler.register('USR1') { restart }
      signal_handler.register('USR2') { status }
      signal_handler.register('HUP') { reload_config }
    end

    def start
      Procodile.log nil, "system", "#{@config.app_name} supervisor started with PID #{::Process.pid}"
      @config.processes.each do |name, process|
        start_instances(process.generate_instances)
      end

      Thread.new do
        socket = ControlServer.new(self)
        socket.listen
      end

      supervise
    end

    def stop
      return if @stopping
      @stopping = true
{'fraction_non_alphanumeric': 0.09877704609595485, 'fraction_numerical': 0.0037629350893697085, 'mean_word_length': 2.839350180505415, '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': '2104818', 'n_tokens_mistral': 641, 'n_tokens_neox': 618, 'n_words': 160}