-
Notifications
You must be signed in to change notification settings - Fork 20
Updates #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates #9
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import type { Bot, BotStatus } from '../types'; | ||
|
|
||
| /** | ||
| * Derives the effective bot status from database status and live container state. | ||
| * | ||
| * Uses Docker health check status to determine if a running container is ready: | ||
| * - health='starting' → bot is initializing | ||
| * - health='healthy' → bot is ready | ||
| * - health='unhealthy' → bot has failed health checks | ||
| * - health='none' → legacy container without health check (treat as running) | ||
| */ | ||
| export function getEffectiveStatus(bot: Bot): BotStatus { | ||
| const containerState = bot.container_status?.state; | ||
|
|
||
| if (containerState === 'running') { | ||
| // Use Docker health check status to determine if bot is ready | ||
| const health = bot.container_status?.health; | ||
| if (health === 'starting') { | ||
| return 'starting'; | ||
| } | ||
| if (health === 'unhealthy') { | ||
| return 'error'; | ||
| } | ||
| // 'healthy' or 'none' (no healthcheck configured) = running | ||
| return 'running'; | ||
| } | ||
|
|
||
| if (containerState === 'exited' || containerState === 'dead') { | ||
| return bot.container_status?.exitCode === 0 ? 'stopped' : 'error'; | ||
| } | ||
|
|
||
| // Fallback to database status | ||
| return bot.status; | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -55,6 +55,13 @@ export class DockerService { | |||||
| [LABEL_BOT_ID]: botId, | ||||||
| [LABEL_BOT_HOSTNAME]: hostname | ||||||
| }, | ||||||
| Healthcheck: { | ||||||
| Test: ['CMD', 'curl', '-sf', `http://localhost:${config.port}/`], | ||||||
|
||||||
| Test: ['CMD', 'curl', '-sf', `http://localhost:${config.port}/`], | |
| Test: ['CMD-SHELL', `nc -z localhost ${config.port}`], |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With 30 retries at 2-second intervals, the container will be marked as unhealthy after 60 seconds of consecutive failures. This is a very high retry count. For context, the botmaker and keyring-proxy containers in docker-compose.yml use only 3 retries. Consider whether 30 retries is appropriate for bot containers, or if this should be reduced to a more typical value like 3-5 retries to detect issues faster.
| Retries: 30, | |
| Retries: 5, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This utility function lacks test coverage. The codebase includes test files (e.g., dashboard/src/api.test.ts), indicating that utility functions should be tested. Consider adding tests for getEffectiveStatus to cover different health status combinations and edge cases, such as when health is 'starting', 'healthy', 'unhealthy', 'none', when container_status is null or undefined, and various container states.