tracker/cmd/chihaya/main.go

62 lines
1.5 KiB
Go
Raw Normal View History

2016-01-25 00:41:39 -05:00
// Copyright 2016 The Chihaya Authors. All rights reserved.
// Use of this source code is governed by the BSD 2-Clause license,
// which can be found in the LICENSE file.
package main
import (
"flag"
"log"
"os"
"os/signal"
"syscall"
2016-03-02 20:18:55 -05:00
"github.com/chihaya/chihaya"
2016-01-25 00:41:39 -05:00
"github.com/chihaya/chihaya/server"
"github.com/chihaya/chihaya/tracker"
// Servers
_ "github.com/chihaya/chihaya/server/http"
2016-03-02 20:59:01 -05:00
_ "github.com/chihaya/chihaya/server/prometheus"
2016-03-02 22:24:38 +01:00
_ "github.com/chihaya/chihaya/server/store"
_ "github.com/chihaya/chihaya/server/store/memory"
// Middleware
_ "github.com/chihaya/chihaya/middleware/deniability"
2016-04-02 18:44:45 -04:00
_ "github.com/chihaya/chihaya/middleware/varinterval"
2016-03-02 22:24:38 +01:00
_ "github.com/chihaya/chihaya/server/store/middleware/client"
2016-03-29 11:54:23 -04:00
_ "github.com/chihaya/chihaya/server/store/middleware/infohash"
2016-04-02 20:22:15 -04:00
_ "github.com/chihaya/chihaya/server/store/middleware/ip"
_ "github.com/chihaya/chihaya/server/store/middleware/response"
2016-01-25 00:41:39 -05:00
)
var configPath string
func init() {
flag.StringVar(&configPath, "config", "", "path to the configuration file")
}
func main() {
flag.Parse()
2016-03-02 20:18:55 -05:00
cfg, err := chihaya.OpenConfigFile(configPath)
2016-01-25 00:41:39 -05:00
if err != nil {
log.Fatal("failed to load config: " + err.Error())
}
tkr, err := tracker.NewTracker(&cfg.Tracker)
if err != nil {
log.Fatal("failed to create tracker: " + err.Error())
}
pool, err := server.StartPool(cfg.Servers, tkr)
if err != nil {
log.Fatal("failed to create server pool: " + err.Error())
}
shutdown := make(chan os.Signal)
signal.Notify(shutdown, syscall.SIGINT, syscall.SIGTERM)
<-shutdown
pool.Stop()
}