go-bgp

a collection of golang BGP tools to monitor, archive and serve
git clone git://git.2f30.org/go-bgp
Log | Files | Refs | README

archive_server.go (1274B)


      1 package main
      2 
      3 import (
      4 	ar "go-bgp/archive"
      5 	"log"
      6 	"os"
      7 	"sync"
      8 	"time"
      9 )
     10 
     11 func main() {
     12 	if len(os.Args) != 2 {
     13 		log.Fatal("usage: ", os.Args[0], " directory ")
     14 	}
     15 	basedirstr := os.Args[1]
     16 	ribmrtar := ar.NewFsArchive(basedirstr, "RIBS")
     17 	ribmrtar.SetDelta(time.Hour * 2)
     18 	wg1 := &sync.WaitGroup{}
     19 	mrtreqc := ribmrtar.Serve(wg1, ribmrtar)
     20 	mrtreqc <- "SCAN"
     21 	ribmrtar.Scanwg.Wait()
     22 	api := new(ar.API)
     23 	api.AddResource(ribmrtar, "/archive/ribs")
     24 	api.AddResource(ribmrtar.Conf, "/archive/ribs/conf")
     25 	api.Start(3000)
     26 	close(mrtreqc)
     27 	wg1.Wait()
     28 	/*
     29 		updfsar := NewXmlArchive(basedirstr, "UPDATES")
     30 		//ribfsar := NewFsArchive(basedirstr, "RIBS")
     31 		wg2	:=  &sync.WaitGroup{}
     32 		updreqc := updfsar.serve(wg2, updfsar)
     33 		//ribreqc := updfsar.serve(wg2)
     34 		updreqc <- "SCAN"
     35 		updfsar.scanwg.Wait()
     36 		//ribfsar.scanwg.Wait()
     37 		//time.Sleep(time.Second*2)
     38 		updreqc <- "DUMPENTRIES"
     39 		api := new(API)
     40 		api.AddResource(updfsar, "/archive/updates")
     41 		//api.AddResource(ribfsar, "/archive/ribs")
     42 		api.AddResource(updfsar.conf, "/archive/updates/conf")
     43 		//api.AddResource(ribfsar.conf, "/archive/ribs/conf")
     44 		api.Start(3000)
     45 		//reqc<-"STOP"
     46 
     47 		close(updreqc)
     48 		//close(ribreqc)
     49 		//wait for it
     50 		//wg1.Wait()
     51 		wg2.Wait()
     52 	*/
     53 	log.Print("all fsarchives stopped. exiting")
     54 }