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
No known key found for this signature in database
GPG Key ID: 8C42FBB0E482C8CF

View File

@ -21,7 +21,12 @@ async function init() {
const password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD; const password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD;
const database = DB_FILE ? fs.readFileSync(DB_FILE) : DB; 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({ pool = mysql.createPool({
connectionLimit: 5, connectionLimit: 5,