mirror of
https://github.com/tiennm99/openai-status-bot.git
synced 2026-10-11 03:13:41 +00:00
fix(config): align mongodb database names
This commit is contained in:
1 parent
b13a976ab0
commit
259b2dfdbd
8 files changed
+15
-15
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
TELEGRAM_BOT_TOKEN=
|
||||
MONGODB_URI=mongodb+srv://<user>:<pass>@<cluster>/
|
||||
MONGODB_DATABASE=openai_status_bot
|
||||
MONGODB_DATABASE=openai-status-bot
|
||||
POLL_INTERVAL=1m
|
||||
HTTP_TIMEOUT=10s
|
||||
LOG_LEVEL=info
|
||||
@@ -37,7 +37,7 @@ a managed MongoDB Atlas cluster, so a reachable `MONGODB_URI` is required to
|
||||
start. The development and production setups share one cluster and differ only
|
||||
by database name (`MONGODB_DATABASE`).
|
||||
|
||||
Production runtime (default Compose file; uses the `MONGODB_DATABASE` from `.env`, default `openai_status_bot`):
|
||||
Production runtime (default Compose file; uses the `MONGODB_DATABASE` from `.env`, default `openai-status-bot`):
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
@@ -45,7 +45,7 @@ cp .env.example .env
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
Development runtime (targets the `development` database):
|
||||
Development runtime (targets the `openai-status-bot-development` database):
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
@@ -66,7 +66,7 @@ go run ./cmd/openai-status-bot
|
||||
|----------|---------|-------------|
|
||||
| `TELEGRAM_BOT_TOKEN` | required | Telegram bot token from BotFather |
|
||||
| `MONGODB_URI` | required | MongoDB connection string, e.g. an Atlas `mongodb+srv://user:pass@cluster/` URI |
|
||||
| `MONGODB_DATABASE` | `openai_status_bot` | Database name; use a separate name (e.g. `development`) to split dev and prod on one cluster |
|
||||
| `MONGODB_DATABASE` | `openai-status-bot` | Database name; use a separate name (e.g. `openai-status-bot-development`) to split dev and prod on one cluster |
|
||||
| `POLL_INTERVAL` | `1m` | Status check interval, valid `5s`-`1h` |
|
||||
| `HTTP_TIMEOUT` | `10s` | HTTP request timeout, valid `1s`-`5m` |
|
||||
| `LOG_LEVEL` | `info` | `debug`, `info`, `warn`/`warning`, or `error` |
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
# Development runtime: bot only, connecting to the shared Atlas cluster.
|
||||
# There is no local datastore; set MONGODB_URI in .env. This file targets the
|
||||
# development database (the MONGODB_DATABASE below overrides any .env value).
|
||||
# openai-status-bot-development database (overrides any .env value).
|
||||
services:
|
||||
bot:
|
||||
build: .
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
MONGODB_DATABASE: development
|
||||
MONGODB_DATABASE: openai-status-bot-development
|
||||
restart: unless-stopped
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Default production runtime: bot only, connecting to the shared Atlas cluster via .env.
|
||||
# Uses the production database (MONGODB_DATABASE in .env, default
|
||||
# openai_status_bot). There is no local datastore.
|
||||
# openai-status-bot). There is no local datastore.
|
||||
services:
|
||||
bot:
|
||||
build: .
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@
|
||||
cp .env.example .env
|
||||
# set TELEGRAM_BOT_TOKEN in .env
|
||||
# set MONGODB_URI to your MongoDB Atlas connection string
|
||||
# docker compose sets MONGODB_DATABASE=development for local development
|
||||
# docker compose sets MONGODB_DATABASE=openai-status-bot-development for local development
|
||||
docker compose -f compose.dev.yaml up --build
|
||||
```
|
||||
|
||||
@@ -26,7 +26,7 @@ Use this for production deployment:
|
||||
cp .env.example .env
|
||||
# set TELEGRAM_BOT_TOKEN in .env
|
||||
# set MONGODB_URI to your MongoDB Atlas connection string
|
||||
# MONGODB_DATABASE defaults to openai_status_bot (production)
|
||||
# MONGODB_DATABASE defaults to openai-status-bot (production)
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
@@ -37,7 +37,7 @@ cp .env.example .env
|
||||
# set TELEGRAM_BOT_TOKEN in .env
|
||||
# set MONGODB_URI to your MongoDB Atlas connection string
|
||||
# export TELEGRAM_BOT_TOKEN or source .env with your shell workflow
|
||||
# MONGODB_DATABASE defaults to openai_status_bot
|
||||
# MONGODB_DATABASE defaults to openai-status-bot
|
||||
go run ./cmd/openai-status-bot
|
||||
```
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ The service uses Telegram `getUpdates` through `github.com/go-telegram/bot`, so
|
||||
|
||||
`telegramOffset` stores the next update ID to resume from. Because `go-telegram/bot` stores the last seen update internally and sends `lastUpdateID + 1` to Telegram, startup passes `telegramOffset - 1` as the initial framework offset when a saved offset exists. The command handler saves `update.ID + 1` after every message update, including non-command messages.
|
||||
|
||||
MongoDB is configured with `MONGODB_URI` and `MONGODB_DATABASE` (default `openai_status_bot`). The OpenAI status source is fixed to `https://status.openai.com`. Docker Compose starts the bot connecting to a managed MongoDB Atlas cluster; there is no bundled local MongoDB service.
|
||||
MongoDB is configured with `MONGODB_URI` and `MONGODB_DATABASE` (production default `openai-status-bot`; development Compose override `openai-status-bot-development`). The OpenAI status source is fixed to `https://status.openai.com`. Docker Compose starts the bot connecting to a managed MongoDB Atlas cluster; there is no bundled local MongoDB service.
|
||||
|
||||
## Failure Behavior
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ const (
|
||||
maxPollInterval = time.Hour
|
||||
minHTTPTimeout = time.Second
|
||||
maxHTTPTimeout = 5 * time.Minute
|
||||
defaultMongoDatabase = "openai_status_bot"
|
||||
defaultMongoDatabase = "openai-status-bot"
|
||||
)
|
||||
|
||||
func LoadFromEnv() (Config, error) {
|
||||
|
||||
@@ -32,14 +32,14 @@ func TestLoadFromEnvDefaultsAndTrimming(t *testing.T) {
|
||||
|
||||
func TestLoadFromEnvAcceptsCustomMongoDatabase(t *testing.T) {
|
||||
setMinimalEnv(t)
|
||||
t.Setenv("MONGODB_DATABASE", " openai_status_bot_dev ")
|
||||
t.Setenv("MONGODB_DATABASE", " openai-status-bot-development ")
|
||||
|
||||
cfg, err := LoadFromEnv()
|
||||
if err != nil {
|
||||
t.Fatalf("LoadFromEnv returned error: %v", err)
|
||||
}
|
||||
if cfg.MongoDatabase != "openai_status_bot_dev" {
|
||||
t.Fatalf("MongoDatabase = %q, want openai_status_bot_dev", cfg.MongoDatabase)
|
||||
if cfg.MongoDatabase != "openai-status-bot-development" {
|
||||
t.Fatalf("MongoDatabase = %q, want openai-status-bot-development", cfg.MongoDatabase)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user