update alias system
This commit is contained in:
parent
d440ba7404
commit
862341ec87
2 changed files with 18 additions and 6 deletions
|
|
@ -2114,9 +2114,7 @@ cron.schedule("0 */4 * * *", async () => {
|
|||
await waitForDb();
|
||||
|
||||
|
||||
await syncService.syncAliases();
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 5000000));
|
||||
await syncService.startSyncDaemon();
|
||||
|
||||
if (process.env.RESYNC_ASSETS === "true") {
|
||||
console.log('Resyncing assets');
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import sequelize from "../database/sequelize";
|
||||
import Alias from "../schemes/Alias";
|
||||
import rpcService from "./rpc.service";
|
||||
|
||||
|
|
@ -17,9 +18,22 @@ class SyncService {
|
|||
enabled: 1
|
||||
}));
|
||||
|
||||
Alias.bulkCreate(preparedData, {
|
||||
ignoreDuplicates: true,
|
||||
})
|
||||
await sequelize.transaction(async (t) => {
|
||||
await Alias.destroy({ where: {}, transaction: t });
|
||||
await Alias.bulkCreate(preparedData, { transaction: t });
|
||||
});
|
||||
}
|
||||
|
||||
async startSyncDaemon() {
|
||||
while (true) {
|
||||
try {
|
||||
await this.syncAliases();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 20000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue