<commit_before>define :component_runit_service, :log_directory => nil,
                                 :svlogd_size => nil,
                                 :svlogd_num => nil,
                                 :ha => nil,
                                 :control => nil,
                                 :action => :enable do
  component = params[:name]
  log_directory = params[:log_directory] || node['private_chef'][component]['log_directory']

  template "#{log_directory}/config" do
    source "config.svlogd"
    cookbook "enterprise"
    mode "0644"
    owner "root"
    group "root"
    variables(
      :svlogd_size => ( params[:svlogd_size] || node['private_chef'][component]['log_rotation']['file_maxbytes']),
      :svlogd_num  => ( params[:svlogd_num] || node['private_chef'][component]['log_rotation']['num_to_keep'])
    )
  end

  runit_service component do
    action :enable
    retries 20
    control params[:control] if params[:control]
    options(
      :log_directory => log_directory
    )
  end

  if params[:action] == :down
    log "stop runit_service[#{component}]" do
      notifies :down, "runit_service[#{component}]", :immediately
    end
  end

  # Keepalive management
  #
  # Our keepalived setup knows which services it must manage by
  # looking for a 'keepalive_me' sentinel file in the service's
  # directory.
  if EnterpriseChef::Helpers.ha?(node)
    is_keepalive_service = params[:ha] || node['private_chef'][component]['ha']
    file "#{node['runit']['sv_dir']}/#{component}/keepalive_me" do
      action is_keepalive_service ? :create : :delete
    end
  end

end<commit_msg>Fixup handling of params[:ha] in component_runit_service<commit_after>define :component_runit_service, :package => 'private_chef',
                                 :log_directory => nil,
                                 :svlogd_size => nil,
                                 :svlogd_num => nil,
                                 :ha => nil,
                                 :control => nil,
                                 :action => :enable do
  component = params[:name]
  log_directory = params[:log_directory] || node[package][component]['log_directory']

  template "#{log_directory}/config" do
    source "config.svlogd"
    cookbook "enterprise"
    mode "0644"
    owner "root"
    group "root"
    variables(
      :svlogd_size => ( params[:svlogd_size] || node[package][component]['log_rotation']['file_maxbytes']),
      :svlogd_num  => ( params[:svlogd_num] || node[package][component]['log_rotation']['num_to_keep'])
    )
  end

  runit_service component do
    action :enable
    retries 20
    control params[:control] if params[:control]
    options(
      :log_directory => log_directory
    )
  end

  if params[:action] == :down
    log "stop runit_service[#{component}]" do
      notifies :down, "runit_service[#{component}]", :immediately
    end
  end

  # Keepalive management
  #
  # Our keepalived setup knows which services it must manage by
  # looking for a 'keepalive_me' sentinel file in the service's
  # directory.
  if EnterpriseChef::Helpers.ha?(node)
    # We need special handling for the ha param, as it's a boolean and
    # could be false, so we explicitly check for nil?
    is_keepalive_service = if params[:ha].nil?
                             node[package][component]['ha']
                           else
                             params[:ha]
                           end
    file "#{node['runit']['sv_dir']}/#{component}/keepalive_me" do
      action is_keepalive_service ? :create : :delete
    end
  end

end
{'fraction_non_alphanumeric': 0.11777839799051075, 'fraction_numerical': 0.0033491487580240022, 'mean_word_length': 2.3621013133208257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '352195', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1046, 'n_words': 244}