updated initialization

This commit is contained in:
Annika Hannig 2021-10-20 18:36:30 +00:00
parent 5471f57dd4
commit 608f998d0a
No known key found for this signature in database
GPG Key ID: 62E226E47DDCE58D
8 changed files with 20 additions and 26 deletions

View File

@ -4,7 +4,7 @@ import (
"flag"
"log"
"github.com/alice-lg/alice-lg/pkg/backend"
"github.com/alice-lg/alice-lg/pkg/store"
)
func main() {
@ -19,31 +19,29 @@ func main() {
flag.Parse()
// Load configuration
if err := backend.InitConfig(*configFilenameFlag); err != nil {
cfg, err = config.LoadConfig(filename)
if err != nil {
log.Fatal(err)
}
// Say hi
printBanner()
log.Println("Using configuration:", backend.AliceConfig.File)
log.Println("Using configuration:", cfg.File)
// Setup local routes store
backend.InitStores()
neighborsStore := store.NewNeighborsStore(cfg)
routesStore := store.NewRoutesStore(cfg)
// Start stores
if backend.AliceConfig.Server.EnablePrefixLookup == true {
go backend.AliceRoutesStore.Start()
}
// Setup local neighbours store
if backend.AliceConfig.Server.EnablePrefixLookup == true {
go backend.AliceNeighboursStore.Start()
go neighborsStore.Start()
go routesStore.Start()
}
// Start the Housekeeping
go backend.Housekeeping(backend.AliceConfig)
go store.Housekeeping(cfg)
// Start HTTP API
go backend.StartHTTPServer()
<-quit

View File

@ -787,14 +787,8 @@ func getSources(config *ini.File) ([]*SourceConfig, error) {
return sources, nil
}
// Try to load configfiles as specified in the files
// list. For example:
//
// ./etc/alice-lg/alice.conf
// /etc/alice-lg/alice.conf
// ./etc/alice-lg/alice.local.conf
//
func loadConfig(file string) (*Config, error) {
// Try to load the config file
func LoadConfig(file string) (*Config, error) {
// Try to get config file, fallback to alternatives
file, err := getConfigFile(file)

View File

@ -1,4 +1,4 @@
package backend
package store
import (
"log"

View File

@ -1,4 +1,4 @@
package backend
package store
import (
"sort"

View File

@ -1,4 +1,4 @@
package backend
package routes
import (
"log"

View File

@ -1,4 +1,4 @@
package backend
package store
import (
"log"

View File

@ -1,4 +1,6 @@
package backend
// Package store provides a store for persisting and
// querying neighbors and routes.
package store
import (
"time"

View File

@ -1,4 +1,4 @@
package backend
package store
import (
"log"