forked from deployphp/deployer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp-fpm.php
47 lines (34 loc) · 1.38 KB
/
php-fpm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/*
## Installing
Add to your _deploy.php_
```php
require 'contrib/php-fpm.php';
```
## 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`.
- `php_fpm_command` – The command to run to reload PHP-fpm. Defaults to `echo "" | sudo -S /usr/sbin/service {{php_fpm_service}} reload`.
## 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;
set('php_fpm_version', function () {
$phpFpmProcess = run("ps aux | grep php-fpm | grep 'master process'");
if (! preg_match('/^.*master process.*(\d\.\d).*$/', $phpFpmProcess, $match)) {
throw new \Exception('Please provide the PHP-fpm version using the `php_fpm_version` option.');
}
return $match[1];
});
set('php_fpm_service', 'php{{php_fpm_version}}-fpm');
set('php_fpm_command', 'echo "" | sudo -S /usr/sbin/service {{php_fpm_service}} reload');
desc('Reload the php-fpm service');
task('php-fpm:reload', function () {
run('{{php_fpm_command}}');
});