kvaps / docker-kolab

Kolab image with nginx, ssl, opendkim, amavis and fail2ban
MIT License
41 stars 19 forks source link

OpenDKIM doesn't start properly #28

Open danbo opened 7 years ago

danbo commented 7 years ago
# restart the container
user@server# docker restart kolab

# enter container
user@server# docker exec -it kolab /bin/bash

# see if opendkim is listening
user@server# netstat -l --numeric | grep 8891
(nothing)
[root@kolab /]#

# check for process - wrapper is there but opendkim is not started

[root@kolab /]# ps aux | grep opendkim
root       174  0.0  0.0  11368  1252 ?        S    00:57   0:00 /bin/bash /bin/service-wrapper.sh opendkim /var/log/maillog opendkim.*\[.*\]:
root       348  0.0  0.0   6508    72 ?        S    00:57   0:00 grep opendkim.*\[.*\]:
root       985  0.0  0.0   8036  1944 ?        S+   00:58   0:00 grep opendkim

# kill and let supervisor restart it

[root@kolab /]# kill 174

# check for process again - running

[root@kolab /]# ps aux | grep opendkim
root       348  0.0  0.0   6508    72 ?        S    00:57   0:00 grep opendkim.*\[.*\]:
root      1002  0.6  0.1  11368  2444 ?        S    00:58   0:00 /bin/bash /bin/service-wrapper.sh opendkim /var/log/maillog opendkim.*\[.*\]:
opendkim  1018  0.0  0.2  95444  4864 ?        Ssl  00:58   0:00 /usr/sbin/opendkim -x /etc/opendkim.conf -P /var/run/opendkim/opendkim.pid
root      1021  0.0  0.0   6508   528 ?        S    00:58   0:00 grep opendkim.*\[.*\]:
root      1025  0.0  0.0   8036  2000 ?        S+   00:58   0:00 grep opendkim

# check for listening - now it looks to be up

[root@kolab /]# netstat -l --numeric | grep 8891
tcp        0      0 127.0.0.1:8891              0.0.0.0:*                   LISTEN
danbo commented 7 years ago

Looks like this only happens when the container is restarted and because upon container shutdown opendkim's pid is not removed, so presumably when it's starting, thinks it's already running and doesn't actually start.

If I delete the pid file and restart the container, it starts as expected.

Not sure why it's not getting deleted as expected. Tried a few things, they didn't work, so I ended up with a hack in supervisord.conf where I force delete the pid before starting the service, ie

[program:opendkim]
command=/bin/service-wrapper.sh         opendkim    '/var/log/maillog'      'opendkim.*\[.*\]:'

turned into

[program:opendkim]
command=/bin/bash -c "rm -f /var/run/opendkim/opendkim.pid && /bin/service-wrapper.sh         opendkim    '/var/log/maillog'      'opendkim.*\[.*\]:'"

... until we figure out a better way.

Now it always starts up as expected upon container restart.