diff --git a/agent/service.go b/agent/service.go index 4f6c6b51..58017579 100644 --- a/agent/service.go +++ b/agent/service.go @@ -90,8 +90,6 @@ func New(ctx context.Context, logger *slog.Logger, eventSvc events.Service, cmp quoteProvider: quoteProvider, } - go svc.sm.Start(ctx) - svc.sm.SendEvent(start) svc.sm.StateFunctions[Idle] = svc.publishEvent(IdleState.String(), json.RawMessage{}) svc.sm.StateFunctions[ReceivingManifest] = svc.publishEvent(InProgress.String(), json.RawMessage{}) svc.sm.StateFunctions[ReceivingAlgorithm] = svc.publishEvent(InProgress.String(), json.RawMessage{}) @@ -101,6 +99,9 @@ func New(ctx context.Context, logger *slog.Logger, eventSvc events.Service, cmp svc.sm.StateFunctions[Running] = svc.runComputation svc.sm.StateFunctions[Failed] = svc.publishEvent(Failed.String(), json.RawMessage{}) + go svc.sm.Start(ctx) + svc.sm.SendEvent(start) + svc.computation = cmp svc.sm.SendEvent(manifestReceived)