I have an openvpn tunnel which runs an
--up script which queries a local mysql database for IP routing information and then applies the routes. However, since both the openvpn and mysql systemd services are configured with the
After=network.target directive, I have a race condition: /var/run/mysqld/mysqld.sock might exist when the
--up script runs, or it might not. If the sock file doesn't exist, then my script dies and the system doesn't initialize properly.
I thought that changing my openvpn.service directive to
After=network.target mysql.service and running
systemctl daemon-reload would do the trick. However, I added
ls -lh /var/run/mysqld/mysqld.sock to the beginning of my
--up script, and it still sometimes reports
ls: cannot access '/var/run/mysqld/mysqld.sock': No such file or directory.
My guess is that systemd's is not using the sock file to determine whether or not mysqld has finished loading but rather some criteria that happens before the sock file is created.
Is there a way to tell systemd to not recognize mysql.service as having started until the sock file has been created?