generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
51 lines (45 loc) · 1.61 KB
/
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
44
45
46
47
48
49
50
51
package main
import (
"context"
"os"
"path/filepath"
"github.com/alecthomas/kong"
"github.com/TBD54566975/ftl"
"github.com/TBD54566975/ftl/backend/runner"
_ "github.com/TBD54566975/ftl/internal/automaxprocs" // Set GOMAXPROCS to match Linux container CPU quota.
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/observability"
)
var cli struct {
Version kong.VersionFlag `help:"Show version."`
LogConfig log.Config `prefix:"log-" embed:""`
ObservabilityConfig observability.Config `embed:"" prefix:"o11y-"`
RunnerConfig runner.Config `embed:""`
}
func main() {
cacheDir, err := os.UserCacheDir()
if err != nil {
panic(err)
}
kctx := kong.Parse(&cli, kong.Description(`
FTL - Towards a 𝝺-calculus for large-scale systems
The Runner is the component of FTL that coordinates with the Controller to spawn
and route to user code.
`), kong.Vars{
"version": ftl.Version,
"deploymentdir": filepath.Join(cacheDir, "ftl-runner", "${runner}", "deployments"),
})
// Substitute in the runner key into the deployment directory.
cli.RunnerConfig.DeploymentDir = os.Expand(cli.RunnerConfig.DeploymentDir, func(key string) string {
if key == "runner" {
return cli.RunnerConfig.Key.String()
}
return key
})
logger := log.Configure(os.Stderr, cli.LogConfig)
ctx := log.ContextWithLogger(context.Background(), logger)
err = observability.Init(ctx, "ftl-runner", ftl.Version, cli.ObservabilityConfig)
kctx.FatalIfErrorf(err, "failed to initialize observability")
err = runner.Start(ctx, cli.RunnerConfig)
kctx.FatalIfErrorf(err)
}