<commit_before># This is an environment file that is to be used when loading the
# Sidekiq Asynch job queue. It loads only what the workers need.
require 'json'
require 'redis'
require 'redis-namespace'
require 'sidekiq'
require 'sidekiq-scheduler'
require 'tierion'

Dir[File.expand_path('../../app/workers/*.rb', __FILE__)].each do |file|
  load file
end

redis_uri = URI.parse(ENV['REDISCLOUD_URL'] ||= 'redis://127.0.0.1:6379')
$redis = Redis.new(uri: redis_uri)

if $redis.blank?
  raise 'Exiting. The $redis client is nil.'
end

if ENV['TIERION_ENABLED'] && ENV['TIERION_USERNAME'].present? && ENV['TIERION_PASSWORD'].present?
  $blockchain = Tierion::HashApi::Client.new()
end

if ENV['TIERION_ENABLED'] && $blockchain.blank?
  raise 'Exiting. TIERION_ENABLED is true, but $blockchain is nil. Bad auth?'
end

Sidekiq.configure_server do |config|
  config.redis = { uri: redis_uri, namespace: 'sidekiq' }
  config.on(:startup) do
    schedule = YAML.load_file(File.expand_path('../../config/sidekiq_scheduler.yml', __FILE__))
    Sidekiq.schedule = schedule
    Sidekiq::Scheduler.dynamic = true
    Sidekiq::Scheduler.reload_schedule!
  end
end

# Register a callback URL for Tierion (optional)
if ENV['TIERION_ENABLED'] && ENV['RACK_ENV'] == 'production'
  callback_uri = ENV['TIERION_SUBSCRIPTION_CALLBACK_URI']
  $blockchain.create_block_subscription(callback_uri) if callback_uri.present?
end
<commit_msg>Add Sidekiq client config as well to try and fix redis 127.0.0.1 issue<commit_after># This is an environment file that is to be used when loading the
# Sidekiq Asynch job queue. It loads only what the workers need.

# Start sidekiq manually with:
# bundle exec sidekiq -c 5 -v -r './config/sidekiq_environment.rb

# Heroku note. This will need to be manually started at least once:
# heroku ps:scale worker=1

require 'json'
require 'redis'
require 'redis-namespace'
require 'sidekiq'
require 'sidekiq-scheduler'
require 'tierion'

Dir[File.expand_path('../../app/workers/*.rb', __FILE__)].each do |file|
  load file
end

redis_uri = URI.parse(ENV['REDISCLOUD_URL'] ||= 'redis://127.0.0.1:6379')
$redis = Redis.new(uri: redis_uri)

if $redis.blank?
  raise 'Exiting. The $redis client is nil.'
end

if ENV['TIERION_ENABLED'] && ENV['TIERION_USERNAME'].present? && ENV['TIERION_PASSWORD'].present?
  $blockchain = Tierion::HashApi::Client.new()
end

if ENV['TIERION_ENABLED'] && $blockchain.blank?
  raise 'Exiting. TIERION_ENABLED is true, but $blockchain is nil. Bad auth?'
end

Sidekiq.configure_client do |config|
  config.redis = { uri: redis_uri, namespace: 'sidekiq' }
end

Sidekiq.configure_server do |config|
  config.redis = { uri: redis_uri, namespace: 'sidekiq' }
  config.on(:startup) do
    schedule = YAML.load_file(File.expand_path('../../config/sidekiq_scheduler.yml', __FILE__))
    Sidekiq.schedule = schedule
    Sidekiq::Scheduler.dynamic = true
    Sidekiq::Scheduler.reload_schedule!
  end
end

# Register a callback URL for Tierion (optional)
if ENV['TIERION_ENABLED'] && ENV['RACK_ENV'] == 'production'
  callback_uri = ENV['TIERION_SUBSCRIPTION_CALLBACK_URI']
  $blockchain.create_block_subscription(callback_uri) if callback_uri.present?
end

{'fraction_non_alphanumeric': 0.13128140703517588, 'fraction_numerical': 0.008793969849246231, 'mean_word_length': 5.020793950850662, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, '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': '5369222', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1144, 'n_words': 286}