2016-01-25 06:41:39 +01: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-03 02:18:55 +01:00
|
|
|
"github.com/chihaya/chihaya"
|
2016-01-25 06:41:39 +01:00
|
|
|
"github.com/chihaya/chihaya/server"
|
|
|
|
"github.com/chihaya/chihaya/tracker"
|
2016-02-16 01:49:25 +01:00
|
|
|
|
|
|
|
_ "github.com/chihaya/chihaya/server/http"
|
2016-03-03 02:59:01 +01: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"
|
|
|
|
_ "github.com/chihaya/chihaya/server/store/middleware/client"
|
|
|
|
_ "github.com/chihaya/chihaya/server/store/middleware/ip"
|
2016-03-29 17:54:23 +02:00
|
|
|
_ "github.com/chihaya/chihaya/server/store/middleware/infohash"
|
2016-04-02 21:42:31 +02:00
|
|
|
_ "github.com/chihaya/chihaya/middleware/deniability"
|
2016-01-25 06:41:39 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var configPath string
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
flag.StringVar(&configPath, "config", "", "path to the configuration file")
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
|
|
|
|
2016-03-03 02:18:55 +01:00
|
|
|
cfg, err := chihaya.OpenConfigFile(configPath)
|
2016-01-25 06:41:39 +01: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()
|
|
|
|
}
|