Skip to content

Commit 4ded121

Browse files
authored
Allowing opcache role to use a Unix socket. (#722)
1 parent fd355e4 commit 4ded121

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
---
22
cache_clear_opcache:
33
# Adapter string to use as argument.
4-
# eg.
4+
# e.g.
55
# --fcgi=127.0.0.1:9000
6-
# Leave blank to use /etc/cachetool.yml
7-
# adapter: "--fcgi=127.0.0.1:9081" # Leave commented to automatically detect the adapter based on PHP version.
6+
# --fcgi=/var/run/php-fpm.sock
7+
# Provide an empty string to use /etc/cachetool.yml
8+
# adapter: "--fcgi=127.0.0.1:9081" # Leave commented to automatically detect the adapter based on PHP version.
9+
unix_socket: false # Set to true to use automatic detection of Unix socket as set by ce-provision
810
# Bins to clear.
911
clear_opcache: true
1012
clear_apcu: false
1113
clear_stat: true
12-
# cachetool_bin: "/path/to/cachetool.phar" # see _init for paths if undefined
14+
# cachetool_bin: "/path/to/cachetool.phar" # see _init for default paths if undefined

roles/cache_clear/cache_clear-opcache/tasks/main.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@
66
executable: /bin/bash
77
register: _php_version
88

9-
- name: Set cachetool adapter.
9+
- name: Set cachetool adapter specified or default to a TCP/IP port.
1010
ansible.builtin.set_fact:
1111
_cachetool_adapter: "{{ cache_clear_opcache.adapter | default('--fcgi=127.0.0.1:90' + _php_version.stdout | replace('.','')) }}"
1212

13+
- name: Override cachetool adapter to be a Unix socket if requested.
14+
ansible.builtin.set_fact:
15+
_cachetool_adapter: "--fcgi=/var/run/php{{ _php_version.stdout | replace('.','') }}-fpm.sock"
16+
when:
17+
- cache_clear_opcache.unix_socket
18+
- cache_clear_opcache.adapter is not defined
19+
20+
# cachetool_bin is set in the _init role.
1321
- name: Clear opcache.
1422
ansible.builtin.command:
1523
cmd: "{{ cachetool_bin }} {{ _cachetool_adapter }} -n opcache:reset"

0 commit comments

Comments
 (0)