From 6bec1fb628b585a0dae9cf103b9086a7e2c46a71 Mon Sep 17 00:00:00 2001 From: worstell Date: Tue, 25 Jun 2024 16:24:45 -0400 Subject: [PATCH] fix: execute startup tasks after serving (#1873) ensure controller is live and db container is provisioned before executing startup tasks --- cmd/ftl/cmd_serve.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cmd/ftl/cmd_serve.go b/cmd/ftl/cmd_serve.go index 56ee421a30..85aad6ad18 100644 --- a/cmd/ftl/cmd_serve.go +++ b/cmd/ftl/cmd_serve.go @@ -79,15 +79,6 @@ func (s *serveCmd) Run(ctx context.Context, projConfig projectconfig.Config) err logger.Infof("Starting FTL with %d controller(s)", s.Controllers) - if len(projConfig.Commands.Startup) > 0 { - for _, cmd := range projConfig.Commands.Startup { - logger.Debugf("Executing startup command: %s", cmd) - if err := exec.Command(ctx, log.Info, ".", "bash", "-c", cmd).Run(); err != nil { - return fmt.Errorf("startup command failed: %w", err) - } - } - } - // Bring up the DB and DAL. dsn, err := s.setupDB(ctx) if err != nil { @@ -146,6 +137,16 @@ func (s *serveCmd) Run(ctx context.Context, projConfig projectconfig.Config) err if err := wg.Wait(); err != nil { return fmt.Errorf("serve failed: %w", err) } + + if len(projConfig.Commands.Startup) > 0 { + for _, cmd := range projConfig.Commands.Startup { + logger.Debugf("Executing startup command: %s", cmd) + if err := exec.Command(ctx, log.Info, ".", "bash", "-c", cmd).Run(); err != nil { + return fmt.Errorf("startup command failed: %w", err) + } + } + } + return nil }