Update MySQL handler to add timeout for DNS query failures

Signed-off-by: Michael Irwin <mikesir87@gmail.com>

I was helping troubleshoot an issue with someone, who ended up
having a typo in their compose file where the MySQL service was
using the name "msyql", which obviously causes DNS to fail. But,
since the db init doesn't time out, it just looks hung. This fixes
that.
This commit is contained in:
Michael Irwin
2022-12-13 16:53:36 -05:00
parent b4d6426abc
commit 8dff10bcaa

View File

@@ -21,7 +21,12 @@ async function init() {
const password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD;
const database = DB_FILE ? fs.readFileSync(DB_FILE) : DB;
await waitPort({ host, port : 3306});
await waitPort({
host,
port: 3306,
timeout: 10000,
waitForDns: true,
});
pool = mysql.createPool({
connectionLimit: 5,