# Defined Type: php::fpm::pool

Defined in:
  manifests/fpm/pool.pp

## Overview

Configure fpm pools

=== Parameters

See the official php-fpm documentation for parameters that are not documented here: http://php.net/manual/en/install.fpm.configuration.php.

[ensure] Remove pool if set to `'absent'`, add otherwise

[listen] On what socket to listen for FastCGI connections, i.e. `'127.0.0.1:9000'' or`'/var/run/php5-fpm.sock'`

[listen_backlog]

[listen_allowed_clients]

[listen_owner] Set owner of the Unix socket

[listen_group] Set the group of the Unix socket

[listen_mode]

[user] The user that php-fpm should run as

[group] The group that php-fpm should run as

[pm]

[pm_max_children]

[pm_start_servers]

[pm_min_spare_servers]

[pm_max_spare_servers]

[pm_max_requests]

[pm_process_idle_timeout]

[pm_status_path]

[ping_path]

[ping_response]

[access_log] The path to the file to write access log requests to

[access_log_format] The format to save the access log entries as

[request_terminate_timeout]

[request_slowlog_timeout]

[security_limit_extensions]

[slowlog]

[template] The template to use for the pool

[rlimit_files]

[rlimit_core]

[chroot]

[chdir]

[catch_workers_output]

[include] Other configuration files to include on this pool

[env] List of environment variables that are passed to the php-fpm from the outside and will be available to php scripts in this pool

[env_value] Hash of environment variables and values as strings to use in php scripts in this pool

[options] An optional hash for any other data.

[php_value] Hash of php_value directives

[php_flag] Hash of php_flag directives

[php_admin_value] Hash of php_admin_value directives

[php_admin_flag] Hash of php_admin_flag directives

[php_directives] List of custom directives that are appended to the pool config

[root_group] UNIX group of the root user

[base_dir] The folder that contains the php-fpm pool configs. This defaults to a sensible default depending on your operating system, like '/etc/php5/fpm/pool.d' or '/etc/php-fpm.d'

Parameters:

- ensure (`Any`) (defaults to: `'present'`)
- listen (`Any`) (defaults to: `'127.0.0.1:9000'`)
- listen_backlog (`Any`) (defaults to: `'-1'`)
- listen_allowed_clients (`Any`) (defaults to: `undef`)
- listen_owner (`Any`) (defaults to: `undef`)
- listen_group (`Any`) (defaults to: `undef`)
- listen_mode (`Any`) (defaults to: `undef`)
- user (`Any`) (defaults to: `$::php::fpm::config::user`)
- group (`Any`) (defaults to: `$::php::fpm::config::group`)
- pm (`Any`) (defaults to: `'dynamic'`)
- pm_max_children (`Any`) (defaults to: `'50'`)
- pm_start_servers (`Any`) (defaults to: `'5'`)
- pm_min_spare_servers (`Any`) (defaults to: `'5'`)
- pm_max_spare_servers (`Any`) (defaults to: `'35'`)
- pm_max_requests (`Any`) (defaults to: `'0'`)
- pm_process_idle_timeout (`Any`) (defaults to: `'10s'`)
- pm_status_path (`Any`) (defaults to: `undef`)
- ping_path (`Any`) (defaults to: `undef`)
- ping_response (`Any`) (defaults to: `'pong'`)
- access_log (`Any`) (defaults to: `undef`)
- access_log_format (`Any`) (defaults to: `'"%R - %u %t \"%m %r\" %s"'`)
- request_terminate_timeout (`Any`) (defaults to: `'0'`)
- request_slowlog_timeout (`Any`) (defaults to: `'0'`)
- security_limit_extensions (`Any`) (defaults to: `undef`)
- slowlog (`Any`) (defaults to: `"/var/log/php-fpm/${name}-slow.log"`)
- template (`Any`) (defaults to: `'php/fpm/pool.conf.erb'`)
- rlimit_files (`Any`) (defaults to: `undef`)
- rlimit_core (`Any`) (defaults to: `undef`)
- chroot (`Any`) (defaults to: `undef`)
- chdir (`Any`) (defaults to: `undef`)
- catch_workers_output (`Any`) (defaults to: `'no'`)
- include (`Any`) (defaults to: `undef`)
- env (`Any`) (defaults to: `[]`)
- env_value (`Any`) (defaults to: `{}`)
- options (`Any`) (defaults to: `{}`)
- php_value (`Any`) (defaults to: `{}`)
- php_flag (`Any`) (defaults to: `{}`)
- php_admin_value (`Any`) (defaults to: `{}`)
- php_admin_flag (`Any`) (defaults to: `{}`)
- php_directives (`Any`) (defaults to: `[]`)
- root_group (`Any`) (defaults to: `$::php::params::root_group`)
- base_dir (`Optional[Stdlib::Absolutepath]`) (defaults to: `undef`)

    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    # File 'manifests/fpm/pool.pp', line 117

    define php::fpm::pool (
      $ensure                                  = 'present',
      $listen                                  = '127.0.0.1:9000',
      $listen_backlog                          = '-1',
      $listen_allowed_clients                  = undef,
      $listen_owner                            = undef,
      $listen_group                            = undef,
      $listen_mode                             = undef,
      $user                                    = $::php::fpm::config::user,
      $group                                   = $::php::fpm::config::group,
      $pm                                      = 'dynamic',
      $pm_max_children                         = '50',
      $pm_start_servers                        = '5',
      $pm_min_spare_servers                    = '5',
      $pm_max_spare_servers                    = '35',
      $pm_max_requests                         = '0',
      $pm_process_idle_timeout                 = '10s',
      $pm_status_path                          = undef,
      $ping_path                               = undef,
      $ping_response                           = 'pong',
      $access_log                              = undef,
      $access_log_format                       = '"%R - %u %t \"%m %r\" %s"',
      $request_terminate_timeout               = '0',
      $request_slowlog_timeout                 = '0',
      $security_limit_extensions               = undef,
      $slowlog                                 = "/var/log/php-fpm/${name}-slow.log",
      $template                                = 'php/fpm/pool.conf.erb',
      $rlimit_files                            = undef,
      $rlimit_core                             = undef,
      $chroot                                  = undef,
      $chdir                                   = undef,
      $catch_workers_output                    = 'no',
      $include                                 = undef,
      $env                                     = [],
      $env_value                               = {},
      $options                                 = {},
      $php_value                               = {},
      $php_flag                                = {},
      $php_admin_value                         = {},
      $php_admin_flag                          = {},
      $php_directives                          = [],
      $root_group                              = $::php::params::root_group,
      Optional[Stdlib::Absolutepath] $base_dir = undef,
    ) {

      # The base class must be included first because it is used by parameter defaults
      if ! defined(Class['php']) {
        warning('You must include the php base class before using any php defined resources')
      }

      $pool = $title

      # Hack-ish to default to user for group too
      $group_final = $group ? {
        undef   => $user,
        default => $group
      }

      # On FreeBSD fpm is not a separate package, but included in the 'php' package.
      # Implies that the option SET+=FPM was set when building the port.
      $real_package = $facts['os']['name'] ? {
        'FreeBSD' => [],
        default   => $::php::fpm::package,
      }

      $pool_base_dir = pick_default($base_dir, $::php::fpm::config::pool_base_dir, $::php::params::fpm_pool_dir)
      if ($ensure == 'absent') {
        file { "${pool_base_dir}/${pool}.conf":
          ensure => absent,
          notify => Class['::php::fpm::service'],
        }
      } else {
        file { "${pool_base_dir}/${pool}.conf":
          ensure  => file,
          notify  => Class['::php::fpm::service'],
          require => Package[$real_package],
          content => template($template),
          owner   => root,
          group   => $root_group,
          mode    => '0644',
        }
      }
    }