Skip to content

Commit

Permalink
Auto clean old files
Browse files Browse the repository at this point in the history
  • Loading branch information
waybackarchiver committed Oct 16, 2021
1 parent 2d08110 commit cf89ac6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ RUN echo @edge https://dl-cdn.alpinelinux.org/alpine/edge/community >> /etc/apk/
py3-setuptools \
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/*

COPY cleaner.sh /
COPY entrypoint.sh /
COPY supervisord.conf /etc/

Expand Down
20 changes: 20 additions & 0 deletions cleaner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
#
# Clean old files

if [ -n "${DEBUG}" ]; then
set -x
fi

clean() {
tick=15
if [ -n "${WAYBACK_CLEAN_TICK}" ]; then
tick="${WAYBACK_CLEAN_TICK}"
fi
if [ -n "${WAYBACK_STORAGE_DIR}" ] && [ -d "${WAYBACK_STORAGE_DIR}" ]; then
echo "Cleaning files on ${WAYBACK_STORAGE_DIR} ..."
find "${WAYBACK_STORAGE_DIR}" -mmin +$tick -type f -exec rm {} +
fi
}

clean
15 changes: 14 additions & 1 deletion supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ command=/bin/sh -c "set -o pipefail && /bin/sh /entrypoint.sh"
numprocs=1
autostart=true
autorestart=true
startsecs=1
startsecs=10
startretries=9999999999999
stderr_logfile=/dev/stderr
stdout_logfile=/dev/stdout
stderr_logfile_maxbytes=0
Expand Down Expand Up @@ -53,3 +54,15 @@ stderr_logfile=/dev/stderr
stdout_logfile=/dev/stdout
stderr_logfile_maxbytes=0
stdout_logfile_maxbytes=0

[program:cleaner]
command=/bin/sh -c 'sleep 60 && set -o pipefail && /bin/sh /cleaner.sh'
numprocs=1
autostart=true
autorestart=true
startsecs=10
startretries=9999999999999
stderr_logfile=/dev/stderr
stdout_logfile=/dev/stdout
stderr_logfile_maxbytes=0
stdout_logfile_maxbytes=0

0 comments on commit cf89ac6

Please sign in to comment.