distinguishing between when DB is just connected and when it's ready for queries (validated)

This commit is contained in:
azivner
2017-12-03 19:18:33 -05:00
parent 3a26054619
commit a3f57622ff
5 changed files with 52 additions and 47 deletions

View File

@@ -8,7 +8,7 @@ const sync = require('./sync');
let startTime = utils.nowTimestamp();
let sentSyncId = [];
setInterval(async () => {
async function sendPing() {
const syncs = await sql.getResults("SELECT * FROM sync WHERE sync_date >= ? AND source_id != ?", [startTime, source_id.currentSourceId]);
startTime = utils.nowTimestamp();
@@ -41,4 +41,6 @@ setInterval(async () => {
for (const syncId of syncIds) {
sentSyncId.push(syncId);
}
}, 1000);
}
sql.dbReady.then(() => setInterval(sendPing, 1000));