-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgoshire_proxy.go
51 lines (41 loc) · 1.13 KB
/
goshire_proxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
//
// An example main for the router process.
//
import (
"log"
// "github.com/trendrr/goshire/cheshire"
"github.com/trendrr/goshire-shards/proxy"
// "os"
"flag"
"strings"
"fmt"
)
var (
config = flag.String("config", "proxy_config.yaml", "path to the yaml config file")
seedAddress = flag.String("seed-http-address", "", "http address to seed a service. comma delimit multiple.")
)
func main() {
// lf, err := os.Create("router.log")
// if err != nil {
// log.Panicf("Coulding open log file -- %s", err)
// }
// //log to a file
// log.SetOutput(lf)
flag.Parse()
r := proxy.NewServerFile(*config)
log.Println("Loading from seeds")
log.Println(*seedAddress)
addresses := make([]string, 0)
for _,add := range(strings.Split(*seedAddress, ",")) {
if !strings.HasPrefix(add, "http://") {
add = fmt.Sprintf("http://%s",add)
}
addresses = append(addresses, add)
}
//now add the services.
r.Seeds(addresses ...)
log.Println("Starting")
//starts listening on all configured interfaces
r.Start()
}