<commit_before>include_recipe "php5::default"

listen_str = node[:php5_fpm][:listen] == "socket" ? node[:php5_fpm][:listen_socket] : "#{node[:php5_fpm][:listen_ip]}:#{node[:php5_fpm][:listen_port]}"

# The default config for php-fpm blows up if there is no /var/www directory
directory "/var/www" do
  recursive true
  action :create
end

package "php5-fpm"

directory node[:php5][:fpm_log_dir] do
  recursive true
  action :create
end

bash "Nuke the existing error log if it exists" do
  code "rm -rf /var/log/php5-fpm.log"
end

template "/etc/logrotate.d/php5-fpm" do
  source "php5-fpm-logrotate.erb"
  backup false
end

# enable php-fpm service
service "php5-fpm" do
  supports :restart => true
  action [:enable, :start]
end

template "/etc/php5/fpm/main.conf" do
  source "php5-fpm.conf.erb"
  backup false
  variables(:listen_str => listen_str)
  notifies :restart, resources(:service => "php5-fpm"), :immediately
end

# TODO: Stats http://forum.nginx.org/read.php?3,56426<commit_msg>Wait until the end of the converge to restart php-fpm<commit_after>include_recipe "php5::default"

listen_str = node[:php5_fpm][:listen] == "socket" ? node[:php5_fpm][:listen_socket] : "#{node[:php5_fpm][:listen_ip]}:#{node[:php5_fpm][:listen_port]}"

# The default config for php-fpm blows up if there is no /var/www directory
directory "/var/www" do
  recursive true
  action :create
end

package "php5-fpm"

directory node[:php5][:fpm_log_dir] do
  recursive true
  action :create
end

bash "Nuke the existing error log if it exists" do
  code "rm -rf /var/log/php5-fpm.log"
end

template "/etc/logrotate.d/php5-fpm" do
  source "php5-fpm-logrotate.erb"
  backup false
end

# enable php-fpm service
service "php5-fpm" do
  supports :restart => true
  action [:enable, :start]
end

template "/etc/php5/fpm/main.conf" do
  source "php5-fpm.conf.erb"
  backup false
  variables(:listen_str => listen_str)
  notifies :restart, resources(:service => "php5-fpm"), :delayed
end

# TODO: Stats http://forum.nginx.org/read.php?3,56426
{'fraction_non_alphanumeric': 0.1400990099009901, 'fraction_numerical': 0.019801980198019802, 'mean_word_length': 4.661064425770308, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '217179', 'n_tokens_mistral': 790, 'n_tokens_neox': 770, 'n_words': 192}