Skip to content

Commit

Permalink
fixed mysql wait
Browse files Browse the repository at this point in the history
  • Loading branch information
vcmirko committed Oct 3, 2024
1 parent 342b461 commit 1be31db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/src/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ async function init(){

// this is at startup, don't start the app until mysql is ready
// rewrite with await
logger.info("Waiting for mysql to start")

async function sleep(millis) {
return new Promise(resolve => setTimeout(resolve, millis));
}
var MYSQL_IS_READY = false
while(!MYSQL_IS_READY){
try{
logger.info("Waiting for mysql to start")
await mysql.do("SELECT 1")
MYSQL_IS_READY = true
}catch(e){
logger.log("Mysql not ready yet")
logger.warning("Mysql not ready yet")
await sleep(5000)
}
}
Expand Down

0 comments on commit 1be31db

Please sign in to comment.