mirror of
https://github.com/bokysan/docker-postfix.git
synced 2024-09-20 06:46:10 +08:00
Fix for #174: Try to refactor healthcheck
This commit is contained in:
parent
df9771b6e2
commit
83b9af5c9b
|
@ -61,7 +61,7 @@ VOLUME [ "/var/spool/postfix", "/etc/postfix", "/etc/opendkim/keys" ]
|
|||
USER root
|
||||
WORKDIR /tmp
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --start-interval=2s --retries=3 CMD printf "EHLO healthcheck\nquit\n" | { while read l ; do sleep 1; echo $l; done } | nc -w 2 127.0.0.1 587 | grep -qE "^220.*ESMTP Postfix"
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --start-interval=2s --retries=3 CMD /scripts/healthcheck.sh
|
||||
|
||||
EXPOSE 587
|
||||
CMD [ "/bin/sh", "-c", "/scripts/run.sh" ]
|
||||
|
|
|
@ -209,9 +209,7 @@ readinessProbe:
|
|||
command:
|
||||
- sh
|
||||
- -c
|
||||
- >-
|
||||
[ ! -f /tmp/container_is_terminating ] &&
|
||||
printf "EHLO healthcheck\nquit\n" | { while read l ; do sleep 1; echo $l; done } | nc -w 2 127.0.0.1 587 | grep -qE "^220.*ESMTP Postfix"
|
||||
- /scripts/healthcheck.sh
|
||||
livenessProbe:
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
|
|
22
scripts/healthcheck.sh
Normal file
22
scripts/healthcheck.sh
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
if [ -f /tmp/container_is_terminating ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
check_postfix() {
|
||||
printf "EHLO healthcheck\nquit\n" | \
|
||||
{ while read l ; do sleep 1; echo $l; done } | \
|
||||
nc -w 2 127.0.0.1 587 | \
|
||||
grep -qE "^220.*ESMTP Postfix"
|
||||
}
|
||||
|
||||
check_dkim() {
|
||||
if [ -f /tmp/no_open_dkim ]; then
|
||||
return
|
||||
fi
|
||||
printf '\x18Clocalhost\x004\x00\x00127.0.0.1\x00' | nc -w 2 127.0.0.1 8891
|
||||
}
|
||||
|
||||
check_postfix
|
||||
check_dkim
|
|
@ -9,8 +9,10 @@ noop() {
|
|||
}
|
||||
|
||||
if [ ! -d /etc/opendkim/keys ]; then
|
||||
touch /tmp/no_open_dkim
|
||||
noop
|
||||
elif [ -z "$(find /etc/opendkim/keys -type f ! -name .)" ]; then
|
||||
touch /tmp/no_open_dkim
|
||||
noop
|
||||
else
|
||||
exec /usr/sbin/opendkim -D -f -x /etc/opendkim/opendkim.conf
|
||||
|
|
Loading…
Reference in a new issue