Skip to content

Commit 644a259

Browse files
igolmanIvan Golman
andauthored
docs: describe caveat and workaround for multiple fpm pools (#366)
* docs: describe caveat and workaround for multiple fpm pools * chore: lint markdown php_fpm_pool.md --------- Co-authored-by: Ivan Golman <[email protected]>
1 parent 9f81c21 commit 644a259

File tree

1 file changed

+48
-6
lines changed

1 file changed

+48
-6
lines changed

documentation/php_fpm_pool.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,52 @@ More info: <https://www.php.net/manual/en/install.fpm.php>
3030

3131
## Examples
3232

33-
Install a FPM pool named 'default'
33+
1. Install a FPM pool named 'default'
3434

35-
```ruby
36-
php_fpm_pool 'default' do
37-
action :install
38-
end
39-
```
35+
```ruby
36+
php_fpm_pool 'default' do
37+
action :install
38+
end
39+
```
40+
41+
2. Multiple FPM Pools
42+
Changes in configuration during provisioning of an FPM pool will lead to a restart of the `phpX.Y-fpm` service.
43+
If more than `5` FPM pools are affected by a configuration change, this will lead to subsequent `5+` service restarts.
44+
However, `systemd` will deny this number of subsequent service restarts with the following error:
45+
46+
```bash
47+
php8.1-fpm.service: Start request repeated too quickly.
48+
php8.1-fpm.service: Failed with result 'start-limit-hit'.
49+
Failed to start The PHP 8.1 FastCGI Process Manager.
50+
```
51+
52+
This behavior is due to the `unified_mode true` setting of an `fpm_pool` custom resource, which is a [default setting](https://docs.chef.io/deprecations_unified_mode/) for `chef-clients v18+`. In this mode, notifications set as `:delayed` within a custom resource action (like `action :install`) are queued to be processed once the action completes (i.e., at the end of the resource `action :install` block), rather than waiting until the end of the Chef client run.
53+
54+
**Possible Workaround**
55+
56+
In a wrapper cookbook, define a `ruby_block` with a call to the `sleep(X)` function, which will be called upon an `fpm_pool` resource update:
57+
58+
```ruby
59+
# frozen_string_literal: true
60+
#
61+
# Cookbook:: my_php
62+
# Recipe:: fpm
63+
64+
ruby_block "wait after_service restart" do
65+
block do
66+
Chef::Log.info("Waiting 5 seconds after php-fpm service restart...")
67+
sleep(5)
68+
end
69+
action :nothing
70+
end
71+
72+
# Fancy loop on all defined pools for this node
73+
node['php']['fpm_pool'].each do |pool_name, parameters|
74+
php_fpm_pool pool_name do
75+
parameters.each do |param, value|
76+
send(param, value)
77+
end unless parameters.nil?
78+
notifies :run, "ruby_block[wait after_service restart]", :immediately
79+
end
80+
end
81+
```

0 commit comments

Comments
 (0)