cleaning some stuff up

master
Jordan Orelli 3 years ago
parent 208bb98577
commit 9b5b6a3d8f

@ -8,9 +8,6 @@ import (
"log" "log"
"os" "os"
"os/signal" "os/signal"
"orel.li/modularium/internal/index"
"orel.li/modularium/internal/ref"
) )
var log_error = log.New(os.Stderr, "", 0) var log_error = log.New(os.Stderr, "", 0)
@ -41,30 +38,6 @@ func sigCancel(ctx context.Context) context.Context {
return ctx return ctx
} }
func serve(args []string) {
path := "./modularium.sock"
indexPath := pathArg{path: "./modules-index.json"}
serveFlags := flag.NewFlagSet("serve", flag.ExitOnError)
serveFlags.StringVar(&path, "l", path, "path for a unix domain socket to listen on")
serveFlags.Var(&indexPath, "index", "an index config")
serveFlags.Parse(args)
idx, err := index.Load(indexPath.path)
if err != nil {
shutdown(err)
}
log_info.Printf("index: %v", idx)
h := handler{
path: ref.New(&path),
index: ref.New(&indexPath),
}
if err := h.run(); err != nil {
bail(1, err.Error())
}
}
func main() { func main() {
sigCancel(context.Background()) sigCancel(context.Background())
root := flag.NewFlagSet("", flag.ExitOnError) root := flag.NewFlagSet("", flag.ExitOnError)

@ -0,0 +1,32 @@
package main
import (
"flag"
"orel.li/modularium/internal/index"
"orel.li/modularium/internal/ref"
)
func serve(args []string) {
path := "./modularium.sock"
indexPath := pathArg{path: "./modules-index.json"}
serveFlags := flag.NewFlagSet("serve", flag.ExitOnError)
serveFlags.StringVar(&path, "l", path, "path for a unix domain socket to listen on")
serveFlags.Var(&indexPath, "index", "an index config")
serveFlags.Parse(args)
idx, err := index.Load(indexPath.path)
if err != nil {
shutdown(err)
}
log_info.Printf("index: %v", idx)
h := handler{
path: ref.New(&path),
index: ref.New(&indexPath),
}
if err := h.run(); err != nil {
bail(1, err.Error())
}
}
Loading…
Cancel
Save