-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpixur.go
57 lines (49 loc) · 1011 Bytes
/
pixur.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
52
53
54
55
56
57
package main // import "pixur.org/pixur"
import (
"context"
"flag"
"log"
beserver "pixur.org/pixur/be/server"
beconfig "pixur.org/pixur/be/server/config"
fehandlers "pixur.org/pixur/fe/handlers"
feserver "pixur.org/pixur/fe/server"
feconfig "pixur.org/pixur/fe/server/config"
)
func main() {
flag.Parse()
ctx := context.Background()
errs := make(chan error)
beready := make(chan struct{})
feready := make(chan struct{})
go func() {
s := new(beserver.Server)
if err := s.Init(ctx, beconfig.Conf); err != nil {
errs <- err
return
}
errs <- s.ListenAndServe(ctx, beready)
}()
go func() {
select {
case <-ctx.Done():
return
case <-beready:
}
s := new(feserver.Server)
fehandlers.RegisterAll(s)
if err := s.Init(ctx, feconfig.Conf); err != nil {
errs <- err
return
}
errs <- s.ListenAndServe(ctx, feready)
}()
go func() {
select {
case <-ctx.Done():
return
case <-feready:
log.Println("Pixur Server Ready")
}
}()
log.Fatal(<-errs)
}