X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/2ad578a24f252706976cddb41bee6cc969f251cd..4343ca5fb6cc86eb887951f4fe16063bab29a238:/daemon.go diff --git a/daemon.go b/daemon.go index 958d6f7..2a93f1d 100644 --- a/daemon.go +++ b/daemon.go @@ -370,10 +370,16 @@ func daemonServe(ctx context.Context, listener net.Listener, bot *TelegramBot, w } hub.snapshot = func(ctx context.Context, snapshot func() error) error { - return messages.Snapshot(func() error { - return daemonSnapshot(ctx, loops, snapshot) - }) + return messages.SnapshotAgents(ctx, snapshot) + } + + runtime := &DaemonChildren{ + ctx: ctx, + cancel: cancel, + root: l, + messages: messages, } + l.tools.children = runtime var workers sync.WaitGroup @@ -449,7 +455,7 @@ func daemonServe(ctx context.Context, listener net.Listener, bot *TelegramBot, w hub.CloseAll() workers.Wait() - return errors.Join(err, whatsappErr, schedulesErr, botErr, errors.Join(childErrors...)) + return errors.Join(err, whatsappErr, schedulesErr, botErr, errors.Join(childErrors...), runtime.Close()) } // daemonRunChild runs a child's turn loop and its schedules until either stops.