property :extra_file_extensions, :kind_of => [String, Array], :default => []
property :fpm_max_children, :kind_of => Integer, :default => 5
property :fpm_request_terminate_timeout, :kind_of => Integer, :default => 300
+property :fpm_prometheus_port, :kind_of => Integer
property :reload_apache, :kind_of => [TrueClass, FalseClass], :default => true
action :create do
"max_execution_time" => "240",
"upload_max_filesize" => "70M",
"post_max_size" => "100M"
+ prometheus_port new_resource.fpm_prometheus_port
end
apache_site new_resource.site do
version "1.0.0"
supports "ubuntu"
depends "apache"
+depends "prometheus"
#
include_recipe "php"
+include_recipe "prometheus"
package "php-fpm"
service "php#{node[:php][:version]}-fpm" do
action [:enable, :start]
end
+
property :php_flags, :kind_of => Hash, :default => {}
property :php_admin_flags, :kind_of => Hash, :default => {}
property :reload_fpm, :kind_of => [TrueClass, FalseClass], :default => true
+property :prometheus_port, :kind_of => Integer
action :create do
template conf_file do
mode "644"
variables new_resource.to_hash
end
+
+ if new_resource.prometheus_port
+ prometheus_exporter "phpfpm" do
+ port new_resource.prometheus_port
+ service service_name
+ command "server"
+ options "--phpfpm.scrape-uri=#{scrape_uri}"
+ end
+ else
+ prometheus_exporter "phpfpm" do
+ action :delete
+ service service_name
+ end
+ end
end
action :delete do
file conf_file do
action :delete
end
+
+ prometheus_exporter "phpfpm" do
+ action :delete
+ service service_name
+ end
end
action_class do
def conf_file
"/etc/php/#{php_version}/fpm/pool.d/#{new_resource.pool}.conf"
end
+
+ def service_name
+ "phpfpm-#{new_resource.pool}"
+ end
+
+ def scrape_uri
+ if new_resource.port
+ "tcp://127.0.0.1:#{new_resource.port}/status"
+ else
+ "unix:///run/php/#{new_resource.pool}.sock;/status"
+ end
+ end
end
def after_created
pm.min_spare_servers = <%= @pm_min_spare_servers %>
pm.max_spare_servers = <%= @pm_max_spare_servers %>
pm.max_requests = <%= @pm_max_requests %>
+pm.status_path = /status
request_terminate_timeout = <%= @request_terminate_timeout %>
property :listen_switch, :kind_of => String, :default => "web.listen-address"
property :listen_type, :kind_of => String, :default => "address"
property :user, :kind_of => String, :default => "root"
+property :command, :kind_of => String
property :options, :kind_of => [String, Array]
property :environment, :kind_of => Hash, :default => {}
+property :service, :kind_of => String
action :create do
systemd_service service_name do
type "simple"
user new_resource.user
environment new_resource.environment
- exec_start "#{executable_path} #{executable_options}"
+ exec_start "#{executable_path} #{new_resource.command} #{executable_options}"
private_tmp true
protect_system "strict"
protect_home true
action_class do
def service_name
- "prometheus-#{new_resource.exporter}-exporter"
+ if new_resource.service
+ "prometheus-#{new_resource.service}-exporter"
+ else
+ "prometheus-#{new_resource.exporter}-exporter"
+ end
end
def executable_path
directory "/srv/wiki.openstreetmap.org"
fpm_max_children 25
+ fpm_prometheus_port 9253
database_name "wiki"
database_user "wiki-user"