diff --git a/buildengine/engine.go b/buildengine/engine.go index 99e24af4ab..93a7fdf7ec 100644 --- a/buildengine/engine.go +++ b/buildengine/engine.go @@ -6,7 +6,6 @@ import ( "crypto/sha256" "errors" "fmt" - "os" "path/filepath" "runtime" "strings" @@ -14,7 +13,6 @@ import ( "connectrpc.com/connect" "github.com/alecthomas/types/pubsub" - "github.com/gofrs/flock" "github.com/jpillora/backoff" "github.com/puzpuzpuz/xsync/v3" "golang.org/x/exp/maps" @@ -85,13 +83,6 @@ func WithListener(listener Listener) Option { // // "dirs" are directories to scan for local modules. func New(ctx context.Context, client ftlv1connect.ControllerServiceClient, moduleDirs []string, externalDirs []string, options ...Option) (*Engine, error) { - logger := log.FromContext(ctx) - lock, err := acquireBuildLock() - if err != nil { - return nil, err - } - logger.Debugf("Acquired lock file at %s", lock.Path()) - ctx = rpc.ContextWithClient(ctx, client) e := &Engine{ client: client, @@ -111,14 +102,6 @@ func New(ctx context.Context, client ftlv1connect.ControllerServiceClient, modul ctx, cancel := context.WithCancel(ctx) e.cancel = cancel - go func() { - <-ctx.Done() - err := lock.Unlock() - if err != nil { - logger.Errorf(err, "failed to unlock file at %s", lock.Path()) - } - }() - projects, err := DiscoverProjects(ctx, moduleDirs, externalDirs) if err != nil { return nil, fmt.Errorf("could not find projects: %w", err) @@ -184,26 +167,6 @@ func (e *Engine) Close() error { return nil } -func acquireBuildLock() (*flock.Flock, error) { - homeDir, err := os.UserHomeDir() - if err != nil { - return nil, err - } - lockFile := filepath.Join(homeDir, ".ftl", "build.lock") - if err := os.MkdirAll(filepath.Dir(lockFile), 0750); err != nil { - return nil, err - } - lock := flock.New(lockFile) - locked, err := lock.TryLock() - if err != nil { - return nil, err - } - if !locked { - return nil, fmt.Errorf("failed to lock file at: %s", lockFile) - } - return lock, nil -} - // Graph returns the dependency graph for the given modules. // // If no modules are provided, the entire graph is returned. An error is returned if diff --git a/buildengine/engine_test.go b/buildengine/engine_test.go index a0faf4eb98..92c4cad651 100644 --- a/buildengine/engine_test.go +++ b/buildengine/engine_test.go @@ -58,13 +58,3 @@ func TestEngine(t *testing.T) { err = engine.Build(ctx) assert.NoError(t, err) } - -func TestDissallowMultipleEngines(t *testing.T) { - ctx := log.ContextWithNewDefaultLogger(context.Background()) - engine, err := buildengine.New(ctx, nil, []string{"testdata/projects/alpha"}, nil) - assert.NoError(t, err) - defer engine.Close() - - _, err = buildengine.New(ctx, nil, []string{"testdata/projects/alpha"}, nil) - assert.Error(t, err) -}