1
0
mirror of https://github.com/alice-lg/alice-lg.git synced 2024-05-11 05:55:03 +00:00
2021-12-07 19:11:11 +01:00

57 lines
1.2 KiB
Go

package main
import (
"context"
"flag"
"log"
"github.com/alice-lg/alice-lg/pkg/config"
"github.com/alice-lg/alice-lg/pkg/http"
"github.com/alice-lg/alice-lg/pkg/store"
"github.com/alice-lg/alice-lg/pkg/store/backends/memory"
)
func main() {
ctx := context.Background()
// Handle commandline parameters
configFilenameFlag := flag.String(
"config", "/etc/alice-lg/alice.conf",
"Alice looking glass configuration file",
)
flag.Parse()
// Load configuration
cfg, err := config.LoadConfig(*configFilenameFlag)
if err != nil {
log.Fatal(err)
}
// Setup local routes store
neighborsBackend := memory.NewNeighborsBackend()
routesBackend := memory.NewRoutesBackend()
neighborsStore := store.NewNeighborsStore(cfg, neighborsBackend)
routesStore := store.NewRoutesStore(neighborsStore, cfg, routesBackend)
// Say hi
printBanner(cfg, neighborsStore, routesStore)
log.Println("Using configuration:", cfg.File)
// Start stores
if cfg.Server.EnablePrefixLookup == true {
go neighborsStore.Start()
go routesStore.Start()
}
// Start the Housekeeping
go store.StartHousekeeping(ctx, cfg)
// Start HTTP API
server := http.NewServer(cfg, routesStore, neighborsStore)
go server.Start()
<-ctx.Done()
}