<commit_before>#!/usr/bin/env ruby

require 'bundler'
Bundler.setup
require_relative '../lib/ganger'

# Logging
$stdout.sync = true
@log = Logger.new(STDOUT)

# Keep track of threads, get a stack trace if a thread blows up
@threads = []
Thread.abort_on_exception = true

# Cleanup when interrupted or sent SIGTERM
def cleanup_for_exit
  puts "Exiting..."
  exit 0
end

Signal.trap('SIGINT') do
  cleanup_for_exit
end

Signal.trap('SIGTERM') do
  cleanup_for_exit
end

# Load configuration
CONFIG_FILE = File.expand_path("../../config/ganger.yaml", __FILE__)
@log.info("Using config file: #{CONFIG_FILE}")
Ganger.configure do |configuration|
  Ganger::YamlConfigLoader.load_from_file(configuration, CONFIG_FILE)
end
@log.info("Loaded configuration from YAML file: #{Ganger.configuration}")

# Start the service
server = TCPServer.new(nil, Ganger.configuration.proxy_listen_port)
loop do
  @threads << Thread.new(server.accept) do |client_socket|
    proxy = Ganger::Proxy.new(client_socket)
    proxy.main_loop
  end
end<commit_msg>Ditch top level instance variables in ganger.rb<commit_after>#!/usr/bin/env ruby

require 'bundler'
Bundler.setup
require_relative '../lib/ganger'

# Logging
$stdout.sync = true
log = Logger.new(STDOUT)

# Keep track of threads, get a stack trace if a thread blows up
@threads = []
Thread.abort_on_exception = true

# Cleanup when interrupted or sent SIGTERM
def cleanup_for_exit
  puts "Exiting..."
  exit 0
end

Signal.trap('SIGINT') do
  cleanup_for_exit
end

Signal.trap('SIGTERM') do
  cleanup_for_exit
end

# Load configuration
CONFIG_FILE = File.expand_path("../../config/ganger.yaml", __FILE__)
log.info("Using config file: #{CONFIG_FILE}")
Ganger.configure do |configuration|
  Ganger::YamlConfigLoader.load_from_file(configuration, CONFIG_FILE)
end
log.info("Loaded configuration from YAML file: #{Ganger.configuration}")

# Start the service
server = TCPServer.new(nil, Ganger.configuration.proxy_listen_port)
loop do
  @threads << Thread.new(server.accept) do |client_socket|
    proxy = Ganger::Proxy.new(client_socket)
    proxy.main_loop
  end
end
{'fraction_non_alphanumeric': 0.11371237458193979, 'fraction_numerical': 0.0009555661729574773, 'mean_word_length': 5.12280701754386, 'pattern_counts': {'":': 0, '<': 7, '<?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': '859654', 'n_tokens_mistral': 694, 'n_tokens_neox': 691, 'n_words': 179}