2021-04-04 10:59:36 +01:00
|
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
|
2021-10-22 23:21:45 +02:00
|
|
|
|
:::caution
|
|
|
|
|
Do **not** reload php-fpm. Some user requests could fail or not complete in the
|
|
|
|
|
process of reloading.
|
|
|
|
|
|
|
|
|
|
Instead, configure your server [properly](https://ï.at/avoid-php-fpm-reloading). If you're using Deployer's provision
|
|
|
|
|
recipe, it's already configured the right way and no php-fpm reload is needed.
|
|
|
|
|
:::
|
|
|
|
|
|
2021-04-04 10:59:36 +01:00
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
|
|
- `php_fpm_version` – The PHP-fpm version. For example: `8.0`.
|
|
|
|
|
- `php_fpm_service` – The full name of the PHP-fpm service. Defaults to `php{{php_fpm_version}}-fpm`.
|
2021-12-06 12:04:47 -05:00
|
|
|
|
- `php_fpm_command` – The command to run to reload PHP-fpm. Defaults to `sudo systemctl reload {{php_fpm_service}}`.
|
2021-04-04 10:59:36 +01:00
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
Start by explicitely providing the current version of PHP-version using the `php_fpm_version`.
|
|
|
|
|
Alternatively, you may use any of the options above to configure how PHP-fpm should reload.
|
|
|
|
|
|
|
|
|
|
Then, add the `php-fpm:reload` task at the end of your deployments by using the `after` method like so.
|
|
|
|
|
|
|
|
|
|
```php
|
|
|
|
|
set('php_fpm_version', '8.0');
|
|
|
|
|
after('deploy', 'php-fpm:reload');
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
namespace Deployer;
|
|
|
|
|
|
2022-03-17 20:23:12 +01:00
|
|
|
|
// Automatically detects by using {{bin/php}}.
|
2021-04-04 10:59:36 +01:00
|
|
|
|
set('php_fpm_version', function () {
|
2022-03-03 21:18:00 +01:00
|
|
|
|
return run('{{bin/php}} -r "printf(\'%d.%d\', PHP_MAJOR_VERSION, PHP_MINOR_VERSION);"');
|
2021-04-04 10:59:36 +01:00
|
|
|
|
});
|
2022-03-17 20:23:12 +01:00
|
|
|
|
|
2021-04-04 10:59:36 +01:00
|
|
|
|
set('php_fpm_service', 'php{{php_fpm_version}}-fpm');
|
|
|
|
|
|
2021-11-08 22:59:39 +01:00
|
|
|
|
desc('Reloads the php-fpm service');
|
2021-04-04 10:59:36 +01:00
|
|
|
|
task('php-fpm:reload', function () {
|
2021-10-22 23:21:45 +02:00
|
|
|
|
warning('Avoid reloading php-fpm [ï.at/avoid-php-fpm-reloading]');
|
2022-03-17 20:23:12 +01:00
|
|
|
|
run('sudo systemctl reload {{php_fpm_service}}');
|
2021-04-04 10:59:36 +01:00
|
|
|
|
});
|