diff --git a/contrib/cachetool.php b/contrib/cachetool.php index e3a9ab058..5e8bd3939 100644 --- a/contrib/cachetool.php +++ b/contrib/cachetool.php @@ -3,12 +3,14 @@ ## Configuration -- **cachetool** *(optional)*: accepts a *string* with the unix socket or ip address to php-fpm. If `cachetool` is not given, then the application will look for a `cachetool.yml` file and read the configuration from there. +- **cachetool** *(optional)*: accepts a *string* or an *array* of strings with the unix socket or ip address to php-fpm. If `cachetool` is not given, then the application will look for a `cachetool.yml` file and read the configuration from there. ```php set('cachetool', '/var/run/php-fpm.sock'); // or set('cachetool', '127.0.0.1:9000'); + // or + set('cachetool', ['/var/run/php-fpm.sock', '/var/run/php-fpm-other.sock]); ``` You can also specify different cachetool settings for each host: @@ -62,16 +64,19 @@ return '{{release_or_current_path}}/cachetool.phar'; }); set('cachetool_options', function () { - $options = get('cachetool'); - $fullOptions = get('cachetool_args'); - - if (strlen($fullOptions) > 0) { - $options = "{$fullOptions}"; - } elseif (strlen($options) > 0) { - $options = "--fcgi={$options}"; + $options = (array)get('cachetool'); + $fullOptions = (string)get('cachetool_args'); + $return = []; + + if ($fullOptions !== '') { + $return = [$fullOptions]; + } elseif (count($options) > 0) { + foreach ($options as $option) { + $return[] = "--fcgi={$option}"; + } } - return $options; + return $return; }); /** @@ -79,7 +84,10 @@ */ desc('Clears OPcode cache'); task('cachetool:clear:opcache', function () { - run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} opcache:reset {{cachetool_options}}"); + $options = get('cachetool_options'); + foreach ($options as $option) { + run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} opcache:reset $option"); + } }); /** @@ -87,7 +95,10 @@ */ desc('Clears APCu system cache'); task('cachetool:clear:apcu', function () { - run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} apcu:cache:clear {{cachetool_options}}"); + $options = get('cachetool_options'); + foreach ($options as $option) { + run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} apcu:cache:clear $option"); + } }); /** @@ -95,5 +106,8 @@ */ desc('Clears file status and realpath caches'); task('cachetool:clear:stat', function () { - run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} stat:clear {{cachetool_options}}"); + $options = get('cachetool_options'); + foreach ($options as $option) { + run("cd {{release_or_current_path}} && {{bin/php}} {{bin/cachetool}} stat:clear $option"); + } }); diff --git a/docs/contrib/cachetool.md b/docs/contrib/cachetool.md index c257ea739..5b2162fe7 100644 --- a/docs/contrib/cachetool.md +++ b/docs/contrib/cachetool.md @@ -15,12 +15,14 @@ require 'contrib/cachetool.php'; ## Configuration -- **cachetool** *(optional)*: accepts a *string* with the unix socket or ip address to php-fpm. If `cachetool` is not given, then the application will look for a `cachetool.yml` file and read the configuration from there. +- **cachetool** *(optional)*: accepts a *string* or an *array* of strings with the unix socket or ip address to php-fpm. If `cachetool` is not given, then the application will look for a `cachetool.yml` file and read the configuration from there. ```php set('cachetool', '/var/run/php-fpm.sock'); // or set('cachetool', '127.0.0.1:9000'); + // or + set('cachetool', ['/var/run/php-fpm.sock', '/var/run/php-fpm-other.sock]); ``` You can also specify different cachetool settings for each host: @@ -58,14 +60,14 @@ http://gordalina.github.io/cachetool/ ## Configuration ### cachetool -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L48) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L50) ### cachetool_url -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L56) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L58) URL to download cachetool from if it is not available @@ -79,14 +81,14 @@ CacheTool 7.x works with PHP >=7.3 ### cachetool_args -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L57) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L59) ### bin/cachetool -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L58) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L60) @@ -99,7 +101,7 @@ return '{{release_or_current_path}}/cachetool.phar'; ### cachetool_options -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L64) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L66) :::info Autogenerated @@ -113,7 +115,7 @@ The value of this configuration is autogenerated on access. ## Tasks ### cachetool:clear:opcache -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L81) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L86) Clears OPcode cache. @@ -121,7 +123,7 @@ Clear opcache cache ### cachetool:clear:apcu -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L89) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L97) Clears APCu system cache. @@ -129,7 +131,7 @@ Clear APCU cache ### cachetool:clear:stat -[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L97) +[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L108) Clears file status and realpath caches.