How does one go about delaying a service init script in Linux until the MySQL socket exists? Does the sleep command in a startup script delay the entire boot process, or are init scripts each executed by a different thread to prevent blocking?
I am trying to get my PolicyD service to start after MySQL. Currently it does in /etc/rc5.d because PolicyD's script starts with S06 while MySQL's starts with S04. The problem is that when the policyd init script runs, if /var/run/mysqld/mysqld.sock doesn't exist, it won't work. If I delay the script for 60 seconds, it works fine (giving MySQL enough time to initialize its system and socket), but I don't want to pause the entire boot process for this long?
I don't suppose MySQL has any virtual facility LSB names to slow down policyd's initialization? (https://wiki.debian.org/LSBInitScripts)
What's the best way to handle this? The init system is multi-threaded since startup scripts run other daemons and programs which can loop? I'm a bit confused...
If it matters, I'm running Ubuntu 16.04. If someone can help clarify how the init process works and how to approach this problem, I'd really appreciate it.