<commit_before># encoding: utf-8
# bundle exec unicorn -c config/unicorn.rb -E production -D

# Environment variables
rails_env = ENV['RAILS_ENV'] || 'production'
cap_root = "#{ENV['HOME']}/#{rails_env}"
shared = "#{cap_root}/shared"

# 8 workers in production
worker_processes (rails_env == 'production' ? 8 : 2)

# Load rails+LinuxFr.org into the master before forking workers for super-fast worker spawn times
preload_app true

# Restart any workers that haven't responded in 30 seconds
timeout 30

# Set the root directory of our Rails app
working_directory "#{cap_root}/current"

# Logs & pid
stdout_path "#{shared}/log/unicorn.log"
stderr_path "#{shared}/log/unicorn.log"
pid "#{shared}/pids/unicorn.pid"

# Listen on a Unix data socket
listen "#{shared}/tmp/sockets/#{rails_env}.sock"


# See http://unicorn.bogomips.org/Sandbox.html
before_exec do |server|
  ENV["BUNDLE_GEMFILE"] = "#{cap_root}/current/Gemfile"
end

before_fork do |server, worker|
  # There's no need for the master process to hold a connection
  ActiveRecord::Base.connection.disconnect!
end

after_fork do |server, worker|
  ActiveRecord::Base.establish_connection

  # Don't share the redis connections
  $redis = Redis.new
  Rails.cache.reconnect
end<commit_msg>Fix redis reconnect at unicorn startup (bis)<commit_after># encoding: utf-8
# bundle exec unicorn -c config/unicorn.rb -E production -D

# Environment variables
rails_env = ENV['RAILS_ENV'] || 'production'
cap_root = "#{ENV['HOME']}/#{rails_env}"
shared = "#{cap_root}/shared"

# 8 workers in production
worker_processes (rails_env == 'production' ? 8 : 2)

# Load rails+LinuxFr.org into the master before forking workers for super-fast worker spawn times
preload_app true

# Restart any workers that haven't responded in 30 seconds
timeout 30

# Set the root directory of our Rails app
working_directory "#{cap_root}/current"

# Logs & pid
stdout_path "#{shared}/log/unicorn.log"
stderr_path "#{shared}/log/unicorn.log"
pid "#{shared}/pids/unicorn.pid"

# Listen on a Unix data socket
listen "#{shared}/tmp/sockets/#{rails_env}.sock"


# See http://unicorn.bogomips.org/Sandbox.html
before_exec do |server|
  ENV["BUNDLE_GEMFILE"] = "#{cap_root}/current/Gemfile"
end

before_fork do |server, worker|
  # There's no need for the master process to hold a connection
  ActiveRecord::Base.connection.disconnect!
end

after_fork do |server, worker|
  ActiveRecord::Base.establish_connection

  # Don't share the redis connections
  $redis = Redis.new
  Rails.cache.instance_variable_set(:@redis, nil)
end
{'fraction_non_alphanumeric': 0.11993708218639403, 'fraction_numerical': 0.006291781360597719, 'mean_word_length': 5.115384615384615, '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': '184195', 'n_tokens_mistral': 883, 'n_tokens_neox': 832, 'n_words': 246}