Skip to content

Commit

Permalink
fix: execute startup tasks after serving (#1873)
Browse files Browse the repository at this point in the history
ensure controller is live and db container is provisioned before
executing startup tasks
  • Loading branch information
worstell authored Jun 25, 2024
1 parent b189037 commit 6bec1fb
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cmd/ftl/cmd_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 6bec1fb

Please sign in to comment.