package main import ( "sync" "git.capotej.com/capotej/communique/cgi" "git.capotej.com/capotej/communique/config" "git.capotej.com/capotej/communique/http" "git.capotej.com/capotej/communique/registry" "github.com/BurntSushi/toml" "github.com/dgraph-io/badger/v3" "go.uber.org/zap" "go.uber.org/zap/zapio" ) func main() { // ctx := context.Background() // Logger logger, _ := zap.NewDevelopment() defer logger.Sync() // flushes buffer, if any log := logger.Sugar() // Config var cfg config.Config //TODO use a flag here _, err := toml.DecodeFile("sample-config.toml", &cfg) if err != nil { log.Fatal(err) } log.Debugf("Loaded TOML Config: %+v", cfg) // DB db, err := badger.Open(badger.DefaultOptions(cfg.DbPath)) if err != nil { log.Fatal(err) } defer db.Close() // Registry registry := registry.NewRegistry(cfg, db) // Servers var mainWg sync.WaitGroup // // Internal CGI Servers cgiServers := cgi.NewServers(log, db) mainWg.Add(1) go cgiServers.Start(cfg) // // External Http Server writer := &zapio.Writer{Log: logger, Level: zap.DebugLevel} defer writer.Close() server := http.NewServer(registry) mainWg.Add(1) go server.Start(writer) mainWg.Wait() }