0

I installed OpenDKIM on Ubuntu Server 18.04, using it with Modoboa, so the config file contains DSN for KeyTable and SigningTable to connect to MariaDB. I noticed that the service always fails to start on reboot, but afterwards I can start it manually with no problem, so I checked syslog and saw these lines:

Jul 31 10:28:35 mail opendkim[897]: opendkim: /etc/opendkim.conf: dsn:mysql://opendkim:pass@127.0.0.1/modoboa/table=dkim?keycol=domain_name?datacol=id: dkimf_db_open(): Can't connect to MySQL server on '127.0.0.1' (111) Jul 31 10:28:35 mail opendkim[991]: opendkim: /etc/opendkim.conf: dsn:mysql://opendkim:pass@127.0.0.1/modoboa/table=dkim?keycol=domain_name?datacol=id: dkimf_db_open(): Can't connect to MySQL server on '127.0.0.1' (111) Jul 31 10:28:37 mail mysqld[1688]: 2018-07-31 10:28:35 139849791634560 [Note] /usr/sbin/mysqld (mysqld 10.1.29-MariaDB-6) starting as process 868 ... Jul 31 10:28:41 mail /etc/mysql/debian-start[2018]: Upgrading MySQL tables if necessary.

From this, you can see that the mysqld is starting right after OpenDKIM, I tried to switch the sequence using: update-rc.d mysql defaults 50 and update-rc.d opendkim defaults 95, this moved the mysql right before the OpenDKIM, but still it didn't have time to intialize so it didn't start either.

For now I fixed it using custom startup script which has sleep 10 && systemctl start opendkim. But I would like some proper solution to fix the startup order.

Thank you.

InToSSH
  • 45
  • 7

1 Answers1

1

On systemd you can change the boot order for the service changing its unit file and setting in the 'After' option what service it should start after. Usually the files for that are in:

/lib/systemd/system/nameofservice.service

The line should look similar to this (update with the proper name)

After=mariadb.service
Adonist
  • 267
  • 1
  • 2
  • 10