diff --git a/cmd/ftl/cmd_dev.go b/cmd/ftl/cmd_dev.go index 4c6a8b592..946bf6d53 100644 --- a/cmd/ftl/cmd_dev.go +++ b/cmd/ftl/cmd_dev.go @@ -16,6 +16,7 @@ import ( "github.com/TBD54566975/ftl/buildengine" "github.com/TBD54566975/ftl/common/moduleconfig" "github.com/TBD54566975/ftl/internal/log" + "github.com/TBD54566975/ftl/internal/rpc" ) type moduleFolderInfo struct { @@ -30,6 +31,8 @@ type devCmd struct { FailureDelay time.Duration `help:"Delay before retrying a failed deploy." default:"500ms"` ReconnectDelay time.Duration `help:"Delay before attempting to reconnect to FTL." default:"1s"` ExitAfterDeploy bool `help:"Exit after all modules are deployed successfully." default:"false"` + NoServe bool `help:"Do not start the FTL server." default:"false"` + ServeCmd serveCmd `embed:"" prefix:"serve-"` } type moduleMap map[string]*moduleFolderInfo @@ -88,17 +91,26 @@ func (m *moduleMap) RebuildDependentModules(ctx context.Context, sch *schema.Mod } } -func (d *devCmd) Run(ctx context.Context, client ftlv1connect.ControllerServiceClient) error { +func (d *devCmd) Run(ctx context.Context) error { logger := log.FromContext(ctx) - logger.Debugf("Watching %s for FTL modules", d.BaseDir) + client := rpc.ClientFromContext[ftlv1connect.ControllerServiceClient](ctx) + ctx, cancel := context.WithCancel(ctx) defer cancel() + wg, ctx := errgroup.WithContext(ctx) + + if !d.NoServe { + wg.Go(func() error { + return d.ServeCmd.Run(ctx) + }) + } + + logger.Debugf("Watching %s for FTL modules", d.BaseDir) + schemaChanges := make(chan *schema.Module, 64) modules := make(moduleMap) - wg, ctx := errgroup.WithContext(ctx) - wg.Go(func() error { return d.watchForSchemaChanges(ctx, client, schemaChanges) }) diff --git a/cmd/ftl/cmd_serve.go b/cmd/ftl/cmd_serve.go index ed7ff8644..e7389fea3 100644 --- a/cmd/ftl/cmd_serve.go +++ b/cmd/ftl/cmd_serve.go @@ -25,6 +25,7 @@ import ( "github.com/TBD54566975/ftl/internal/bind" "github.com/TBD54566975/ftl/internal/exec" "github.com/TBD54566975/ftl/internal/log" + "github.com/TBD54566975/ftl/internal/rpc" "github.com/TBD54566975/ftl/internal/slices" ) @@ -41,8 +42,9 @@ type serveCmd struct { const ftlContainerName = "ftl-db-1" -func (s *serveCmd) Run(ctx context.Context, client ftlv1connect.ControllerServiceClient) error { +func (s *serveCmd) Run(ctx context.Context) error { logger := log.FromContext(ctx) + client := rpc.ClientFromContext[ftlv1connect.ControllerServiceClient](ctx) if s.Background { runInBackground(logger)