mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-04-25 04:09:12 +00:00
fix(DiscordService): retry bootstrap process 10 times
This commit is contained in:
parent
dc4400aa34
commit
fb122015cb
1 changed files with 19 additions and 5 deletions
|
@ -31,6 +31,9 @@ class DiscordService extends Service {
|
||||||
Authorization: `Shared ${this.rpcSecret}`,
|
Authorization: `Shared ${this.rpcSecret}`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.bootstrapRetries = 0
|
||||||
|
this.bootstrapRetriesMax = 10
|
||||||
|
|
||||||
this.bootstrap().catch(e => {
|
this.bootstrap().catch(e => {
|
||||||
console.error(`bootstrap failure`, e)
|
console.error(`bootstrap failure`, e)
|
||||||
process.exit(-1)
|
process.exit(-1)
|
||||||
|
@ -38,11 +41,22 @@ class DiscordService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
async bootstrap() {
|
async bootstrap() {
|
||||||
|
setTimeout(() => {
|
||||||
|
try {
|
||||||
const ownUser = await this.rpc.ownUser(new Empty(), this.sharedHeaders)
|
const ownUser = await this.rpc.ownUser(new Empty(), this.sharedHeaders)
|
||||||
this.ownUser = ownUser.toObject()
|
this.ownUser = ownUser.toObject()
|
||||||
|
|
||||||
const listGuilds = await this.rpc.listGuilds(new Empty(), this.sharedHeaders)
|
const listGuilds = await this.rpc.listGuilds(new Empty(), this.sharedHeaders)
|
||||||
this.syncGuilds(listGuilds.toObject().guildsList)
|
this.syncGuilds(listGuilds.toObject().guildsList)
|
||||||
|
} catch (e) {
|
||||||
|
this.bootstrapRetries++
|
||||||
|
if (this.bootstrapRetries < this.bootstrapRetriesMax) {
|
||||||
|
return this.bootstrap()
|
||||||
|
} else {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
ownGm(server) {
|
ownGm(server) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue