forked from alicebob/ssp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (36 loc) · 834 Bytes
/
main.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
package main
import (
"encoding/json"
"flag"
"io/ioutil"
"log"
"net/http"
"github.com/alicebob/ssp/ssp"
)
type Config struct {
DSPs []ssp.DSP `json:"dsps"`
Placements []ssp.Placement `json:"placements"`
}
var (
config = flag.String("config", "./ssp.json", "config file")
listen = flag.String("listen", ":9998", "listen")
public = flag.String("public", "http://localhost:9998", "public")
)
func main() {
flag.Parse()
f, err := ioutil.ReadFile(*config)
if err != nil {
log.Fatal(err)
}
var c Config
if err := json.Unmarshal(f, &c); err != nil {
log.Fatal(err)
}
log.Printf("configured DSPs:")
for _, d := range c.DSPs {
log.Printf(" - %s", d.Name)
}
s := NewDaemon(*public, c.DSPs)
log.Printf("listening on %s...", *listen)
log.Fatal(http.ListenAndServe(*listen, mux(s, c.Placements)))
}