From c312807790390b63c536486ad505e286d8b3fef7 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Fri, 14 Jun 2024 15:33:13 +1000 Subject: [PATCH] fix: ftl dev notifies when all deployments are up to date (#1778) fixes #1706 when both of these things happen: - we update a deployment successfully - the engine idles for long enough for the file watcher to do 2 cycles then we log "All modules deployed, watching for changes..." --- buildengine/engine.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/buildengine/engine.go b/buildengine/engine.go index 93a7fdf7ec..84fab1d995 100644 --- a/buildengine/engine.go +++ b/buildengine/engine.go @@ -278,10 +278,18 @@ func (e *Engine) watchForModuleChanges(ctx context.Context, period time.Duration }) // Watch for file and schema changes + didUpdateDeployments := false for { + var completedUpdatesTimer <-chan time.Time + if didUpdateDeployments { + completedUpdatesTimer = time.After(period * 2) + } select { case <-ctx.Done(): return ctx.Err() + case <-completedUpdatesTimer: + logger.Infof("All modules deployed, watching for changes...") + didUpdateDeployments = false case event := <-watchEvents: switch event := event.(type) { case WatchEventProjectAdded: @@ -291,6 +299,8 @@ func (e *Engine) watchForModuleChanges(ctx context.Context, period time.Duration err := e.buildAndDeploy(ctx, 1, true, config.Key) if err != nil { logger.Errorf(err, "deploy %s failed", config.Key) + } else { + didUpdateDeployments = true } } case WatchEventProjectRemoved: @@ -299,6 +309,8 @@ func (e *Engine) watchForModuleChanges(ctx context.Context, period time.Duration err := teminateModuleDeployment(ctx, e.client, module.Module) if err != nil { logger.Errorf(err, "terminate %s failed", module.Module) + } else { + didUpdateDeployments = true } } e.projectMetas.Delete(config.Key) @@ -323,6 +335,8 @@ func (e *Engine) watchForModuleChanges(ctx context.Context, period time.Duration case ExternalLibrary: logger.Errorf(err, "build failed for library %q: %v", project.Config().Key, err) } + } else { + didUpdateDeployments = true } } case change := <-schemaChanges: @@ -350,6 +364,8 @@ func (e *Engine) watchForModuleChanges(ctx context.Context, period time.Duration err = e.buildAndDeploy(ctx, 1, true, dependentProjectKeys...) if err != nil { logger.Errorf(err, "deploy %s failed", change.Name) + } else { + didUpdateDeployments = true } } }