aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-02-21 16:00:31 +0900
committerOphestra <cat@gensokyo.uk>2025-02-21 16:06:24 +0900
commitc64b8163e79d47f1e710c1d067589bb393f8463c (patch)
treec4ffa5b89982af6362f1d65bf2ff2af299600574 /main.go
parent9d9a165379798acb237c9071ea865f26cfba8be7 (diff)
app: separate instance from process state
This works better for the implementation. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/main.go b/main.go
index 7896a199..067071a8 100644
--- a/main.go
+++ b/main.go
@@ -173,7 +173,7 @@ func main() {
config.Command = append(config.Command, args[2:]...)
// invoke app
- runApp(config)
+ runApp(app.MustNew(std), config)
panic("unreachable")
case "run": // run app in permissive defaults usage pattern
@@ -300,7 +300,7 @@ func main() {
}
// invoke app
- runApp(config)
+ runApp(app.MustNew(std), config)
panic("unreachable")
// internal commands
@@ -318,7 +318,7 @@ func main() {
panic("unreachable")
}
-func runApp(config *fst.Config) {
+func runApp(a fst.App, config *fst.Config) {
rs := new(fst.RunState)
ctx, stop := signal.NotifyContext(context.Background(),
syscall.SIGINT, syscall.SIGTERM)
@@ -328,12 +328,10 @@ func runApp(config *fst.Config) {
seccomp.CPrintln = log.Println
}
- if a, err := app.New(std); err != nil {
- log.Fatalf("cannot create app: %s", err)
- } else if err = a.Seal(config); err != nil {
+ if sa, err := a.Seal(config); err != nil {
fmsg.PrintBaseError(err, "cannot seal app:")
internal.Exit(1)
- } else if err = a.Run(ctx, rs); err != nil {
+ } else if err = sa.Run(ctx, rs); err != nil {
if rs.Time == nil {
fmsg.PrintBaseError(err, "cannot start app:")
} else {