<commit_before>include_recipe 'sidekiq::service'

node['sidekiq'].each do |application, config|
  deploy = node['deploy'][application]

  opsworks_deploy_user do
    deploy_data deploy
  end

  opsworks_deploy_dir do
    user deploy['user']
    group deploy['group']
    path deploy['deploy_to']
  end

  # Allow deploy user to restart workers
  template "/etc/sudoers.d/#{deploy['user']}" do
    mode 0440
    source 'sudoer.erb'
    variables :user => deploy['user']
  end

  config_directory = "#{deploy['deploy_to']}/shared/config"

  workers = configured_workers(config)
  workers.each do |worker, options|
    # Convert attribute classes to plain old ruby objects
    config = options['config'] ? options['config'].to_hash : {}

    (options[:process_count] || 1).times do |n|
      template "#{config_directory}/sidekiq_#{worker}#{n+1}.yml" do
        owner node['owner_name']
        group node['owner_name']
        mode 0644
        source 'sidekiq.yml.erb'
        variables config
      end
    end
  end

  template "/etc/monit.d/sidekiq_#{application}.monitrc" do
    mode 0644
    source 'sidekiq_monitrc.erb'
    variables({
      application:  application,
      deploy:       deploy,
      environment:  OpsWorks::Escape.escape_double_quotes(deploy['environment_variables']),
      syslog:       config['syslog'] || false,
      workers:      workers
    })
    notifies :reload, 'service[monit]', :delayed
  end

end
<commit_msg>Reload monit immediately so the service is known<commit_after>include_recipe 'sidekiq::service'

node['sidekiq'].each do |application, config|
  deploy = node['deploy'][application]

  opsworks_deploy_user do
    deploy_data deploy
  end

  opsworks_deploy_dir do
    user deploy['user']
    group deploy['group']
    path deploy['deploy_to']
  end

  # Allow deploy user to restart workers
  template "/etc/sudoers.d/#{deploy['user']}" do
    mode 0440
    source 'sudoer.erb'
    variables :user => deploy['user']
  end

  config_directory = "#{deploy['deploy_to']}/shared/config"

  workers = configured_workers(config)
  workers.each do |worker, options|
    # Convert attribute classes to plain old ruby objects
    config = options['config'] ? options['config'].to_hash : {}

    (options[:process_count] || 1).times do |n|
      template "#{config_directory}/sidekiq_#{worker}#{n+1}.yml" do
        owner node['owner_name']
        group node['owner_name']
        mode 0644
        source 'sidekiq.yml.erb'
        variables config
      end
    end
  end

  template "/etc/monit.d/sidekiq_#{application}.monitrc" do
    mode 0644
    source 'sidekiq_monitrc.erb'
    variables({
      application:  application,
      deploy:       deploy,
      environment:  OpsWorks::Escape.escape_double_quotes(deploy['environment_variables']),
      syslog:       config['syslog'] || false,
      workers:      workers
    })
    notifies :reload, 'service[monit]', :immediately
  end

end

{'fraction_non_alphanumeric': 0.12061328790459966, 'fraction_numerical': 0.009540034071550256, 'mean_word_length': 3.2674418604651163, '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': '6167273', 'n_tokens_mistral': 963, 'n_tokens_neox': 909, 'n_words': 213}