Skip to content

Commit 8e18781

Browse files
committed
Issues-470: run flush cache on start/restart vanilla-forums
1 parent 4a8afa4 commit 8e18781

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,10 @@ RUN if [ "$ENV" = "dev" ]; then \
8181
apt-get clean && \
8282
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*; \
8383
echo 'extension=tideways.so\ntideways.connection=tcp://tideways-daemon:9135\ntideways.enable_cli=0\n' >> opt/docker/etc/php/php.ini; \
84-
fi
84+
fi
85+
86+
# Copy custom supervisor's configs and scripts
87+
# Netcat is used to connect to a memcached server
88+
RUN apt-get update && apt-get install -y netcat
89+
COPY ./services/flush_cache.conf /opt/docker/etc/supervisor.d/
90+
COPY ./services/flush_cache.sh /opt/docker/bin/service.d/

services/flush_cache.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[group:flush_cache]
2+
programs=flush_cache
3+
priority=1
4+
5+
[program:flush_cache]
6+
command=/opt/docker/bin/service.d/flush_cache.sh
7+
process_name=%(program_name)s
8+
startsecs=0
9+
startretries=0
10+
autostart=true
11+
autorestart=false
12+
stdout_logfile=/dev/stdout
13+
stdout_logfile_maxbytes=0
14+
stderr_logfile=/dev/stderr
15+
stderr_logfile_maxbytes=0

services/flush_cache.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
MEMCACHED_SERVER_HOST=$(echo $MEMCACHED_SERVER| cut -d':' -f 1)
3+
MEMCACHED_SERVER_PORT=$(echo $MEMCACHED_SERVER| cut -d':' -f 2)
4+
echo flush_cache.sh: connecting to $MEMCACHED_SERVER
5+
echo flush_all | nc -q5 $MEMCACHED_SERVER_HOST $MEMCACHED_SERVER_PORT
6+
nc_exit_code=$?
7+
if [ $nc_exit_code != 0 ]; then
8+
echo flush_cache.sh: exit code $nc_exit_code
9+
else
10+
echo flush_cache.sh: connection was made and completed successfully
11+
fi

0 commit comments

Comments
 (0)