<commit_before>require 'sidekiq'
require 'autoscaler/sidekiq'
require 'autoscaler/heroku_scaler'

heroku = nil
if ENV['HEROKU_APP']
  heroku = Autoscaler::HerokuScaler.new
end

Sidekiq.configure_client do |config|
  if heroku
    config.client_middleware do |chain|
      chain.add Autoscaler::Sidekiq::Client, 'default' => heroku
    end
  end
end

Sidekiq.configure_server do |config|
  config.server_middleware do |chain|
    if heroku
      p "[Sidekiq] Running on Heroku, autoscaler is used"
      chain.add(Autoscaler::Sidekiq::Server, heroku, 60) # 60 seconds timeout
    else
      p "[Sidekiq] Running locally, so autoscaler isn't used"
    end
  end
end

# Source: http://manuel.manuelles.nl/blog/2012/11/13/scalable-heroku-worker-for-sidekiq/<commit_msg>Disable sidekiq autoscaling on Heroku<commit_after># require 'sidekiq'
# require 'autoscaler/sidekiq'
# require 'autoscaler/heroku_scaler'
#
# ##
# # Sidekiq Autoscaling on Heroku
# heroku = nil
# if ENV['HEROKU_APP']
#   heroku = Autoscaler::HerokuScaler.new
# end

# Sidekiq.configure_client do |config|
#   if heroku
#     config.client_middleware do |chain|
#       chain.add Autoscaler::Sidekiq::Client, 'default' => heroku
#     end
#   end
# end

# Sidekiq.configure_server do |config|
#   config.server_middleware do |chain|
#     if heroku
#       p "[Sidekiq] Running on Heroku, autoscaler is used"
#       chain.add(Autoscaler::Sidekiq::Server, heroku, 60) # 60 seconds timeout
#     else
#       p "[Sidekiq] Running locally, so autoscaler isn't used"
#     end
#   end
# end

# Source: http://manuel.manuelles.nl/blog/2012/11/13/scalable-heroku-worker-for-sidekiq/
{'fraction_non_alphanumeric': 0.11571254567600488, 'fraction_numerical': 0.014616321559074299, 'mean_word_length': 3.9044776119402984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5604477', 'n_tokens_mistral': 630, 'n_tokens_neox': 593, 'n_words': 136}