mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 19:01:08 +02:00
The Go binary's config.go hardcoded "postgresql://…/mana" as the DATABASE_URL fallback, but no database named "mana" exists locally or in the macmini compose stack — the platform DB is mana_platform. Anyone running the crawler without an explicit override got a "database \"mana\" does not exist" crash at startup. The dev:crawler script in package.json had been papering over this by setting DATABASE_URL explicitly; drop that override now that the binary default is correct. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package config
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/mana/shared-go/envutil"
|
|
)
|
|
|
|
type Config struct {
|
|
Port int
|
|
DatabaseURL string
|
|
|
|
RedisHost string
|
|
RedisPort int
|
|
RedisPassword string
|
|
|
|
UserAgent string
|
|
DefaultRateLimit float64
|
|
DefaultMaxDepth int
|
|
DefaultMaxPages int
|
|
Timeout int // ms
|
|
Concurrency int
|
|
|
|
CORSOrigins []string
|
|
}
|
|
|
|
func Load() *Config {
|
|
rateLimit, _ := strconv.ParseFloat(envutil.Get("CRAWLER_DEFAULT_RATE_LIMIT", "2"), 64)
|
|
|
|
return &Config{
|
|
Port: envutil.GetInt("PORT", 3023),
|
|
DatabaseURL: envutil.Get("DATABASE_URL", "postgresql://mana:devpassword@localhost:5432/mana_platform"),
|
|
RedisHost: envutil.Get("REDIS_HOST", "localhost"),
|
|
RedisPort: envutil.GetInt("REDIS_PORT", 6379),
|
|
RedisPassword: envutil.Get("REDIS_PASSWORD", ""),
|
|
UserAgent: envutil.Get("CRAWLER_USER_AGENT", "ManaCrawler/1.0 (+https://mana.io/bot)"),
|
|
DefaultRateLimit: rateLimit,
|
|
DefaultMaxDepth: envutil.GetInt("CRAWLER_DEFAULT_MAX_DEPTH", 3),
|
|
DefaultMaxPages: envutil.GetInt("CRAWLER_DEFAULT_MAX_PAGES", 100),
|
|
Timeout: envutil.GetInt("CRAWLER_TIMEOUT", 30000),
|
|
Concurrency: envutil.GetInt("QUEUE_CONCURRENCY", 5),
|
|
CORSOrigins: envutil.GetSlice("CORS_ORIGINS", []string{"http://localhost:3000", "http://localhost:5173"}),
|
|
}
|
|
}
|