// Command core is the bot gateway: it talks to Telegram, owns the queue and // the database, serves the HTTP API and, by default, runs an embedded // download worker. package main import ( "context" "flag" "fmt" "os" "os/signal" "syscall" "github.com/noderunners/dlbot/internal/app" "github.com/noderunners/dlbot/internal/config" ) func main() { configPath := flag.String("config", "", "path to a TOML config file (optional, env vars override it)") flag.Parse() cfg, err := config.Load(*configPath) if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(2) } log := app.NewLogger(cfg.Log, app.Secrets(cfg)...) ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) defer stop() a, err := app.New(ctx, app.Options{Config: cfg, Log: log}) if err != nil { log.Error("startup failed", "err", err) os.Exit(1) } if err := a.Run(ctx); err != nil { log.Error("core exited with error", "err", err) os.Exit(1) } }