blob: 0854e0c4d60701a75117548402632e50431f2be0 (
plain) (
tree)
|
|
package main
import (
"flag"
"fmt"
"log"
"net/http"
"git.icyphox.sh/legit/config"
"git.icyphox.sh/legit/routes"
)
func main() {
var cfg string
flag.StringVar(&cfg, "config", "./config.yaml", "path to config file")
flag.Parse()
c, err := config.Read(cfg)
if err != nil {
log.Fatal(err)
}
if err := Unveil("/usr/local/bin/git", "rx"); err != nil {
log.Fatalf("unveil: %s", err)
}
if err := UnveilPaths([]string{
"/dev/null",
c.Dirs.Static,
c.Repo.ScanPath,
c.Dirs.Templates,
},
"r"); err != nil {
log.Fatalf("unveil: %s", err)
}
mux := routes.Handlers(c)
addr := fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port)
log.Println("starting server on", addr)
log.Fatal(http.ListenAndServe(addr, mux))
}
|