<commit_before>#
# Cookbook Name:: blackfire
# Recipe:: agent
#
# Copyright 2014-2015, SensioLabs
# See LICENSE file
#

include_recipe "#{cookbook_name}::repository"

agent_version = node[cookbook_name]['agent']['version'] ? node[cookbook_name]['agent']['version'] : Blackfire::Versions.agent(node)

agent_version << '-1' if platform_family?('rhel', 'fedora')

package 'blackfire-agent' do
  version agent_version
end

template '/etc/blackfire/agent' do
  source 'agent.erb'
  variables(
    'ca_cert' => node[cookbook_name]['agent']['ca_cert'],
    'collector' => node[cookbook_name]['agent']['collector'],
    'server_id' => node[cookbook_name]['agent']['server_id'],
    'server_token' => node[cookbook_name]['agent']['server_token'],
    'log_file' => node[cookbook_name]['agent']['log_file'],
    'log_level' => node[cookbook_name]['agent']['log_level'],
    'socket' => node[cookbook_name]['agent']['socket'],
    'spec' => node[cookbook_name]['agent']['spec']
  )
end

service 'blackfire-agent' do
  supports status: true, start: true, stop: true, restart: true
  action [:enable]
  subscribes :restart, 'template[/etc/blackfire/agent]',  node[cookbook_name]['agent']['restart_mode']
end<commit_msg>minor #9 Prevent restart with no server credentials which causes exit code 1 (Zaid Daba'een)<commit_after>#
# Cookbook Name:: blackfire
# Recipe:: agent
#
# Copyright 2014-2015, SensioLabs
# See LICENSE file
#

include_recipe "#{cookbook_name}::repository"

agent_version = node[cookbook_name]['agent']['version'] ? node[cookbook_name]['agent']['version'] : Blackfire::Versions.agent(node)

agent_version << '-1' if platform_family?('rhel', 'fedora')

package 'blackfire-agent' do
  version agent_version
end

template '/etc/blackfire/agent' do
  source 'agent.erb'
  variables(
    'ca_cert' => node[cookbook_name]['agent']['ca_cert'],
    'collector' => node[cookbook_name]['agent']['collector'],
    'server_id' => node[cookbook_name]['agent']['server_id'],
    'server_token' => node[cookbook_name]['agent']['server_token'],
    'log_file' => node[cookbook_name]['agent']['log_file'],
    'log_level' => node[cookbook_name]['agent']['log_level'],
    'socket' => node[cookbook_name]['agent']['socket'],
    'spec' => node[cookbook_name]['agent']['spec']
  )
end

service 'blackfire-agent' do
  not_if { node[cookbook_name]['agent']['server_id'].to_s.empty? }
  not_if { node[cookbook_name]['agent']['server_token'].to_s.empty? }
  supports status: true, start: true, stop: true, restart: true
  action [:enable]
  subscribes :restart, 'template[/etc/blackfire/agent]',  node[cookbook_name]['agent']['restart_mode']
end
{'fraction_non_alphanumeric': 0.1872146118721461, 'fraction_numerical': 0.0076103500761035, 'mean_word_length': 6.755162241887906, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '1951060', 'n_tokens_mistral': 893, 'n_tokens_neox': 874, 'n_words': 159}