-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.go
More file actions
51 lines (44 loc) · 1.2 KB
/
main.go
File metadata and controls
51 lines (44 loc) · 1.2 KB
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 implements the entrypoint for the application.
package main
import (
"os"
"runtime"
"strconv"
"time"
"github.com/alecthomas/kong"
"github.com/fivenet-app/fivenet/v2026/cmd"
"github.com/fivenet-app/fivenet/v2026/cmd/envs"
"github.com/fivenet-app/fivenet/v2026/pkg/version"
)
func main() {
// https://github.com/DataDog/go-profiler-notes/blob/main/block.md#overhead
// Thanks, to the authors of this document!
runtime.SetBlockProfileRate(20000)
runtime.SetMutexProfileFraction(100)
ctx := kong.Parse(&cmd.Cli,
kong.Vars{
"version": version.Version,
},
)
// Cli flag overrides env var
if cmd.Cli.Config != "" {
if err := os.Setenv(envs.ConfigFileEnvVar, cmd.Cli.Config); err != nil {
panic(err)
}
}
if cmd.Cli.SkipMigrations != nil {
if err := os.Setenv(envs.SkipDBMigrationsEnv, strconv.FormatBool(*cmd.Cli.SkipMigrations)); err != nil {
panic(err)
}
}
if cmd.Cli.IgnoreRequirements != nil {
if err := os.Setenv(envs.IgnoreRequirementsEnv, strconv.FormatBool(*cmd.Cli.IgnoreRequirements)); err != nil {
panic(err)
}
}
if cmd.Cli.StartTimeout <= 0 {
cmd.Cli.StartTimeout = 180 * time.Second
}
err := ctx.Run(&cmd.Context{})
ctx.FatalIfErrorf(err)
}