-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (34 loc) · 814 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
43
package main
import (
"flag"
"log"
"github.com/42LoCo42/einauth/config"
"github.com/42LoCo42/einauth/db"
"github.com/42LoCo42/einauth/server"
"github.com/go-faster/errors"
)
func main() {
if err := start(); err != nil {
log.Fatal(err)
}
}
func start() (err error) {
address := flag.String("address", ":9001", "Address to listen on")
configPath := flag.String("config", "einauth.yaml", "Path to config file")
dbPath := flag.String("db", "einauth.db", "Path to database file")
flag.Parse()
if err = config.Init(*configPath); err != nil {
return err
}
if err := db.Init(*dbPath); err != nil {
return err
}
server, err := server.Init()
if err != nil {
return err
}
if err := server.Start(*address); err != nil {
return errors.Wrap(err, "failed to start server")
}
return nil
}