<commit_before><%
require 'shellwords'

$crontab = []

def home_dir(*paths)
  File.join '/home', node[:current_user], *paths
end

def deploy_dir(*paths)
  home_dir node.chef_environment, *paths
end

def aws_dir(*paths)
  deploy_dir 'aws', *paths
end

def dashboard_dir(*paths)
  deploy_dir 'dashboard', *paths
end

def pegasus_dir(*paths)
  deploy_dir 'pegasus', *paths
end

def bin_dir(*paths)
  pegasus_dir('sites.v3', 'code.org', 'bin', *paths)
end

def cronjob(params)
  time = params[:at].to_s
  action = params[:do].to_s

  notify = params[:notify].to_s
  action = "#{aws_dir('cronjob')} #{action.shellescape} #{notify}".strip

  $crontab << "#{time} #{action}"
end

def crontab()
  $crontab.join("\n")
end

if node['cdo-apps']['daemon']
  unless node.chef_environment == 'production'
    cronjob at:'@reboot', do:"#{deploy_dir('bin','solr-server')} 2>&1 > #{pegasus_dir('log','solr.log')}"
  end

  if node.chef_environment == 'staging'
    cronjob at:'@reboot', do:home_dir('.dropbox-dist', 'dropboxd')
    cronjob at:'*/5 * * * *', do:deploy_dir('bin', 'import_google_sheets')
    cronjob at:'*/2 * * * *', do:pegasus_dir('sites','virtual','run_server_generate_curriculum_pdfs'), notify:'<EMAIL>'
    cronjob at:'*/2 * * * *', do:pegasus_dir('sites','virtual','collate_pdfs'), notify:'<EMAIL>'
    cronjob at:'*/2 * * * *', do:dashboard_dir('bin','build_scripts'), notify:'<EMAIL>'
    cronjob at:'*/5 * * * *', do:deploy_dir('bin','fetch-external-resources'), notify:'<EMAIL>'
  end

  if node.chef_environment == 'production'
    cronjob at:'*/15 * * * *', do:deploy_dir('bin','activity-monitor')
    cronjob at:'@daily', do:deploy_dir('bin', 'send_workshop_reminder_emails'), notify:'<EMAIL>'
  end

  cronjob at:'*/1 * * * *', do:deploy_dir('bin', 'process_forms')
  cronjob at:'*/5 * * * *', do:deploy_dir('bin', 'analyze_hoc_activity')
  cronjob at:'*/1 * * * *', do:deploy_dir('bin', 'deliver_poste_messages')
  cronjob at:'*/1 * * * *', do:"#{deploy_dir('bin', 'geocode_hoc_activity')} 2>&1 > /dev/null"

  build_target = node.chef_environment == 'test' ? 'test-websites' : 'websites'
  cronjob at:'*/1 * * * *', do:"#{aws_dir('build_and_mail_log')} #{build_target}", notify:'<EMAIL>'
end

cronjob at:'45 * * * *', do:"#{deploy_dir('bin','upload-logs-to-s3')} dashboard pegasus"
%>
#
# node: <%= node.name %>
# environment: <%= node.chef_environment %>
# daemon: <%= !!node['cdo-apps']['daemon'] %>
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
EMAIL=<EMAIL>
HOME=<%= home_dir %>
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8

<%= crontab %>
<commit_msg>Add index-users to crontab<commit_after><%
require 'shellwords'

$crontab = []

def home_dir(*paths)
  File.join '/home', node[:current_user], *paths
end

def deploy_dir(*paths)
  home_dir node.chef_environment, *paths
end

def aws_dir(*paths)
  deploy_dir 'aws', *paths
end

def dashboard_dir(*paths)
  deploy_dir 'dashboard', *paths
end

def pegasus_dir(*paths)
  deploy_dir 'pegasus', *paths
end

def bin_dir(*paths)
  pegasus_dir('sites.v3', 'code.org', 'bin', *paths)
end

def cronjob(params)
  time = params[:at].to_s
  action = params[:do].to_s

  notify = params[:notify].to_s
  action = "#{aws_dir('cronjob')} #{action.shellescape} #{notify}".strip

  $crontab << "#{time} #{action}"
end

def crontab()
  $crontab.join("\n")
end

if node['cdo-apps']['daemon']
  unless node.chef_environment == 'production'
    cronjob at:'@reboot', do:"#{deploy_dir('bin','solr-server')} 2>&1 > #{pegasus_dir('log','solr.log')}"
  end

  if node.chef_environment == 'staging'
    cronjob at:'@reboot', do:home_dir('.dropbox-dist', 'dropboxd')
    cronjob at:'*/5 * * * *', do:deploy_dir('bin', 'import_google_sheets')
    cronjob at:'*/2 * * * *', do:pegasus_dir('sites','virtual','run_server_generate_curriculum_pdfs'), notify:'<EMAIL>'
    cronjob at:'*/2 * * * *', do:pegasus_dir('sites','virtual','collate_pdfs'), notify:'<EMAIL>'
    cronjob at:'*/2 * * * *', do:dashboard_dir('bin','build_scripts'), notify:'<EMAIL>'
    cronjob at:'*/5 * * * *', do:deploy_dir('bin','fetch-external-resources'), notify:'<EMAIL>'
  end

  if node.chef_environment == 'production'
    cronjob at:'*/15 * * * *', do:deploy_dir('bin','activity-monitor')
    cronjob at:'@daily', do:deploy_dir('bin', 'send_workshop_reminder_emails'), notify:'<EMAIL>'
    cronjob at:'*/1 * * * *', do:deploy_dir('bin', 'index-users-in-solr')
  end

  cronjob at:'*/1 * * * *', do:deploy_dir('bin', 'process_forms')
  cronjob at:'*/5 * * * *', do:deploy_dir('bin', 'analyze_hoc_activity')
  cronjob at:'*/1 * * * *', do:deploy_dir('bin', 'deliver_poste_messages')
  cronjob at:'*/1 * * * *', do:"#{deploy_dir('bin', 'geocode_hoc_activity')} 2>&1 > /dev/null"

  build_target = node.chef_environment == 'test' ? 'test-websites' : 'websites'
  cronjob at:'*/1 * * * *', do:"#{aws_dir('build_and_mail_log')} #{build_target}", notify:'<EMAIL>'
end

cronjob at:'45 * * * *', do:"#{deploy_dir('bin','upload-logs-to-s3')} dashboard pegasus"
%>
#
# node: <%= node.name %>
# environment: <%= node.chef_environment %>
# daemon: <%= !!node['cdo-apps']['daemon'] %>
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
EMAIL=<EMAIL>
HOME=<%= home_dir %>
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8

<%= crontab %>

{'fraction_non_alphanumeric': 0.2239848914069877, 'fraction_numerical': 0.008876298394711992, 'mean_word_length': 5.388419782870929, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 37, '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': '6030806', 'n_tokens_mistral': 2195, 'n_tokens_neox': 2103, 'n_words': 329}