- main.go: DOCKER_PATH=/config + /config.json (was /config/config.json)
- vite.config.ts: skipWaiting+clientsClaim forces new SW immediately;
navigateFallback: null prevents SW from serving stale index.html;
globPatterns excludes HTML so navigation always hits the network
- server.go: gqlOpName handles shorthand { field } syntax
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/brasse-b/archivum/internal/config"
|
|
"github.com/brasse-b/archivum/internal/graph"
|
|
)
|
|
|
|
func main() {
|
|
cfgPath := configPath()
|
|
log.Printf("config path: %s", cfgPath)
|
|
|
|
cfg, err := config.Load(cfgPath)
|
|
if err != nil {
|
|
if errors.Is(err, config.ErrRequireSetup) {
|
|
log.Printf("no config found — starting in setup mode (wizard at http://localhost:4000/)")
|
|
} else {
|
|
log.Fatalf("failed to load config: %v", err)
|
|
}
|
|
} else {
|
|
log.Printf("config loaded — storage: %s db: %s", cfg.StoragePath, cfg.DBPath)
|
|
}
|
|
|
|
addr := ":4000"
|
|
if cfg != nil && cfg.ListenAddr != "" {
|
|
addr = cfg.ListenAddr
|
|
}
|
|
|
|
srv := graph.NewServer(cfg, cfgPath)
|
|
|
|
log.Printf("Archivum listening on %s", addr)
|
|
if err := http.ListenAndServe(addr, srv); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func configPath() string {
|
|
// CONFIG_DIR points directly to the config directory (preferred).
|
|
if p := os.Getenv("CONFIG_DIR"); p != "" {
|
|
return p + "/config.json"
|
|
}
|
|
// DOCKER_PATH is also set to the config directory in docker-compose
|
|
// (the container mounts the config dir at /config, so DOCKER_PATH=/config).
|
|
if p := os.Getenv("DOCKER_PATH"); p != "" {
|
|
return p + "/config.json"
|
|
}
|
|
return "config.json"
|
|
}
|