main.go
// socle is a read-only web host for local git repositories:
// browsing of committed state at refs, and anonymous fetch over smart HTTP.
// Nothing in it can write to a repo.
package main
import (
"flag"
"log"
"net/http"
"os"
"vitrine/display"
)
func main() {
configPath := flag.String("config", "", "path to the socle config file (required; there is no default location)")
listen := flag.String("listen", ":8080", "listen address")
themeSeed := flag.String("theme-seed", "", "theme name override (default: first dot-segment of the hostname)")
flag.Parse()
if *configPath == "" {
log.Fatal("socle: the -config flag is required")
}
seed := *themeSeed
if seed == "" {
hostname, err := os.Hostname()
if err != nil {
log.Fatalf("socle: cannot determine hostname for theming (use -theme-seed to bypass): %v", err)
}
seed = display.HostLabel(hostname)
}
cfg, err := loadConfig(*configPath)
if err != nil {
log.Fatal("socle: ", err)
}
repos, warnings := openAll(cfg)
for _, w := range warnings {
log.Print("socle: ", w)
}
log.Printf("socle: serving %d repos on %s", len(repos), *listen)
log.Fatal(http.ListenAndServe(*listen, newServer(repos, display.NewTheme(seed))))
}
main.go · 1.2 KiB · 01cc598cda