-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
43 lines (35 loc) · 992 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
//go:generate go install github.com/volatiletech/sqlboiler/v4
//go:generate go install github.com/volatiletech/sqlboiler-sqlite3
//go:generate go run github.com/volatiletech/sqlboiler/v4 --wipe --no-tests sqlite3
import (
"context"
"errors"
"fmt"
"os"
"os/signal"
"syscall"
"github.com/joho/godotenv"
"github.com/sethvargo/go-envconfig"
"github.com/stephenafamo/warden/cmd"
"github.com/stephenafamo/warden/internal"
)
func main() {
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer cancel()
// Load env variables from a .env file if present
err := godotenv.Overload(".env")
if err != nil {
// Ignore error if file is not present
if !errors.Is(err, os.ErrNotExist) {
panic(err)
}
}
settings := internal.Settings{}
if err := envconfig.Process(ctx, &settings); err != nil {
panic(fmt.Errorf("error parsing config: %w", err))
}
if err := cmd.Execute(ctx, settings); err != nil {
panic(err)
}
}