Skip to content

Commit

Permalink
Merge pull request #8 from bytemate/feat/add-heartbeat
Browse files Browse the repository at this point in the history
✨ Add heartbeat
  • Loading branch information
fuergaosi233 authored Jan 21, 2023
2 parents cf3c003 + 748fcc6 commit c2ca61f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/chatgpt/chatgpt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,19 @@ export class ChatgptService {
await this.startChatgptInstance(account.email);
}
}
// Update account status to Running
@Cron('1 * * * * *')
async heartbeat() {
const emails = Array.from(this.chatgptPoolService.accounts);
// update db account status
this.logger.debug(`Update account status: ${emails}`);
this.prismaService.chatGPTAccount.updateMany({
where: { email: { in: emails } },
data: { status: 'Starting' },
});
this.prismaService.chatGPTAccount.updateMany({
where: { email: { notIn: emails } },
data: { status: 'Running' },
});
}
}

0 comments on commit c2ca61f

Please sign in to comment.