fix: anchor gitignore binary pattern, track cmd/palette

This commit is contained in:
2026-09-09 02:04:03 -05:00
parent a604c5906a
commit 8125eb4c3b
2 changed files with 49 additions and 1 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
palette /palette
palette.db palette.db
palette.db-shm palette.db-shm
palette.db-wal palette.db-wal
+48
View File
@@ -0,0 +1,48 @@
// Command palette is the palette pastebin server entrypoint: flag parsing
// and wiring of the store, API, and web packages.
package main
import (
"log"
"os"
"net/http"
"time"
"palette/internal/api"
"palette/internal/store"
"palette/internal/web"
)
func main() {
// #40: --reset-admin-key regenerates the admin key and exits.
if len(os.Args) > 1 && os.Args[1] == "--reset-admin-key" {
api.HandleResetAdminKey(api.EnvOr("PALETTE_DB", "palette.db"))
return
}
cfg := api.Config{
Addr: api.EnvOr("PALETTE_ADDR", ":8080"),
DBPath: api.EnvOr("PALETTE_DB", "palette.db"),
MaxTextBytes: int64(api.EnvIntOr("PALETTE_MAX_TEXT", 5*1024*1024)),
MaxItemBytes: int64(api.EnvIntOr("PALETTE_MAX_ITEM", 25*1024*1024)),
}
st, err := store.OpenStore(cfg.DBPath)
if err != nil {
log.Fatal(err)
}
adminKey, err := api.ResolveAdminKey(cfg.DBPath)
if err != nil {
log.Fatal(err)
}
ss := api.LoadSettingsStore(cfg.DBPath, cfg)
st.StartSweeper(time.Minute, ss.Get().CustomSlugReservationDays)
ui, err := web.New()
if err != nil {
log.Fatal(err)
}
srv := api.NewServer(st, cfg, ui, ss, adminKey)
log.Printf("palette listening on %s", cfg.Addr)
log.Fatal(http.ListenAndServe(cfg.Addr, srv.Routes()))
}