main.go no longer fatals on ErrRequireSetup — it passes cfg=nil to NewServer. NewServer returns REQUIRE_SETUP on every GraphQL call when cfg is nil, and also adds CORS headers and serves the Vue SPA from /srv/archivum/ui. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
39 lines
773 B
Go
39 lines
773 B
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() {
|
|
cfg, err := config.Load(configPath())
|
|
if err != nil && !errors.Is(err, config.ErrRequireSetup) {
|
|
log.Fatalf("failed to load config: %v", err)
|
|
}
|
|
|
|
// cfg may be nil when REQUIRE_SETUP — NewServer handles that gracefully.
|
|
addr := ":4000"
|
|
if cfg != nil && cfg.ListenAddr != "" {
|
|
addr = cfg.ListenAddr
|
|
}
|
|
|
|
srv := graph.NewServer(cfg)
|
|
|
|
log.Printf("Archivum listening on %s", addr)
|
|
if err := http.ListenAndServe(addr, srv); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func configPath() string {
|
|
if p := os.Getenv("DOCKER_PATH"); p != "" {
|
|
return p + "/config/config.json"
|
|
}
|
|
return "config.json"
|
|
}
|