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

54 lines
1014 B
Go
Raw Normal View History

2017-05-16 13:39:59 +02:00
package main
2017-05-16 15:22:40 +02:00
import (
2021-10-22 22:17:04 +02:00
"context"
2017-05-19 16:16:14 +02:00
"flag"
2017-05-16 15:22:40 +02:00
"log"
2017-05-16 13:39:59 +02:00
2021-10-22 22:17:04 +02:00
"github.com/alice-lg/alice-lg/pkg/config"
2021-10-25 22:03:10 +02:00
"github.com/alice-lg/alice-lg/pkg/http"
2021-10-20 18:36:30 +00:00
"github.com/alice-lg/alice-lg/pkg/store"
2021-03-22 16:25:47 +01:00
)
2017-05-18 15:23:36 +02:00
2017-05-16 13:39:59 +02:00
func main() {
2021-10-25 22:03:10 +02:00
done := make(chan bool)
2021-10-22 22:17:04 +02:00
ctx := context.Background()
2021-03-22 17:35:20 +01:00
2017-05-19 16:16:14 +02:00
// Handle commandline parameters
configFilenameFlag := flag.String(
"config", "/etc/alice-lg/alice.conf",
2017-05-19 16:16:14 +02:00
"Alice looking glass configuration file",
)
flag.Parse()
2017-05-16 15:22:40 +02:00
// Load configuration
2021-10-20 18:36:30 +00:00
cfg, err = config.LoadConfig(filename)
2021-10-22 22:17:04 +02:00
if err != nil {
2017-05-19 16:16:14 +02:00
log.Fatal(err)
}
// Say hi
2021-10-26 23:11:42 +02:00
printBanner(cfg)
2021-10-20 18:36:30 +00:00
log.Println("Using configuration:", cfg.File)
2017-05-16 15:22:40 +02:00
2017-06-23 12:36:32 +02:00
// Setup local routes store
2021-10-20 18:36:30 +00:00
neighborsStore := store.NewNeighborsStore(cfg)
routesStore := store.NewRoutesStore(cfg)
2017-07-04 12:36:48 +02:00
2021-03-22 17:35:20 +01:00
// Start stores
2021-10-22 22:17:04 +02:00
if config.EnablePrefixLookup == true {
go neighborsStore.Start(ctx)
go routesStore.Start(ctx)
2017-07-04 12:36:48 +02:00
}
2017-06-23 17:40:19 +02:00
// Start the Housekeeping
2021-10-25 22:03:10 +02:00
go store.StartHousekeeping(ctx, cfg)
2017-05-16 15:22:40 +02:00
2021-10-22 22:17:04 +02:00
// Start HTTP API
2021-10-25 22:03:10 +02:00
server := http.NewServer(cfg, routesStore, neighborsStore)
go server.Start()
2017-05-18 14:44:50 +02:00
2021-10-25 22:03:10 +02:00
<-done
2017-05-16 13:39:59 +02:00
}