Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
HUAHUAI23 committed Jun 28, 2024
1 parent fc38f74 commit c9df03f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
DedicatedDatabaseState,
} from '../entities/dedicated-database'
import { DedicatedDatabaseService } from './dedicated-database.service'
import { TASK_LOCK_INIT_TIME } from 'src/constants'
import { ServerConfig, TASK_LOCK_INIT_TIME } from 'src/constants'
import { Injectable, Logger } from '@nestjs/common'
import { RegionService } from 'src/region/region.service'
import { ClusterService } from 'src/region/cluster/cluster.service'
Expand All @@ -25,6 +25,10 @@ export class DedicatedDatabaseTaskService {

@Cron(CronExpression.EVERY_SECOND)
async tick() {
if (ServerConfig.DISABLED_INSTANCE_TASK) {
return
}

this.handleDeletingPhase().catch((err) => {
this.logger.error(err)
})
Expand Down Expand Up @@ -95,6 +99,7 @@ export class DedicatedDatabaseTaskService {
return
}

await this.dbService.databaseConnectionIsOk(appid)
manifest = await this.dbService.getDeployManifest(region, user, appid)
const unavailable = manifest?.status?.phase !== 'Running'
if (unavailable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,19 @@ export class DedicatedDatabaseService {
}
}

async databaseConnectionIsOk(appid: string) {
try {
const { client } = await this.findAndConnect(appid)
const admin = client.db('admin')
const replSetStatus = await admin.command({ replSetGetStatus: 1 })
console.log(replSetStatus)

return true
} catch (error) {
return false
}
}

async checkDatabaseSyncLimit(uid: ObjectId) {
const count = await SystemDatabase.db
.collection<DatabaseSyncRecord>('DatabaseSyncRecord')
Expand Down

0 comments on commit c9df03f

Please sign in to comment.