Skip to content

Commit

Permalink
fix: ftl dev notifies when all deployments are up to date (#1778)
Browse files Browse the repository at this point in the history
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..."
  • Loading branch information
matt2e authored Jun 14, 2024
1 parent 9ddfdc8 commit c312807
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions buildengine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit c312807

Please sign in to comment.