aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/app.go
blob: 102c273a90989b7e1f24dc6401f12cf2ae688e94 (plain)
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
// Package app implements high-level hakurei container behaviour.
package app

import (
	"context"
	"log"
	"os"

	"hakurei.app/container"
	"hakurei.app/hst"
	"hakurei.app/internal/app/state"
)

// Main runs an app according to [hst.Config] and terminates. Main does not return.
func Main(ctx context.Context, msg container.Msg, config *hst.Config) {
	var id state.ID
	if err := state.NewAppID(&id); err != nil {
		log.Fatal(err)
	}

	seal := outcome{syscallDispatcher: direct{}}
	if err := seal.finalise(ctx, msg, &id, config); err != nil {
		printMessageError("cannot seal app:", err)
		os.Exit(1)
	}

	seal.main(msg)
	panic("unreachable")
}