Skip to content

Commit

Permalink
fix --process-compose-file issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Lagoja committed Aug 3, 2023
1 parent 02e522e commit 5155490
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Devbox interface {
Remove(ctx context.Context, pkgs ...string) error
RestartServices(ctx context.Context, services ...string) error
RunScript(ctx context.Context, scriptName string, scriptArgs []string) error
Services() (services.Services, error)
Services(userProcessCompose string) (services.Services, error)
// Shell generates the devbox environment and launches nix-shell as a child process.
Shell(ctx context.Context) error
StartProcessManager(ctx context.Context, requestedServices []string, background bool, processComposeFileOrDir string) error
Expand Down
17 changes: 9 additions & 8 deletions internal/impl/devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func (d *Devbox) saveCfg() error {
return d.cfg.SaveTo(d.ProjectDir())
}

func (d *Devbox) Services() (services.Services, error) {
func (d *Devbox) Services(userProcessCompose string) (services.Services, error) {
pluginSvcs, err := d.pluginManager.GetServices(
d.PackagesAsInputs(),
d.cfg.Include,
Expand All @@ -487,7 +487,7 @@ func (d *Devbox) Services() (services.Services, error) {
return nil, err
}

userSvcs := services.FromUserProcessCompose(d.projectDir)
userSvcs := services.FromUserProcessCompose(d.projectDir, userProcessCompose)

svcSet := lo.Assign(pluginSvcs, userSvcs)
keys := make([]string, 0, len(svcSet))
Expand Down Expand Up @@ -515,7 +515,7 @@ func (d *Devbox) StartServices(ctx context.Context, serviceNames ...string) erro
return d.StartProcessManager(ctx, serviceNames, true, "")
}

svcSet, err := d.Services()
svcSet, err := d.Services("")
if err != nil {
return err
}
Expand Down Expand Up @@ -563,7 +563,7 @@ func (d *Devbox) StopServices(ctx context.Context, allProjects bool, serviceName
return services.StopProcessManager(ctx, d.projectDir, d.writer)
}

svcSet, err := d.Services()
svcSet, err := d.Services("")
if err != nil {
return err
}
Expand All @@ -585,7 +585,7 @@ func (d *Devbox) ListServices(ctx context.Context) error {
return d.RunScript(ctx, "devbox", []string{"services", "ls"})
}

svcSet, err := d.Services()
svcSet, err := d.Services("")
if err != nil {
return err
}
Expand Down Expand Up @@ -631,7 +631,7 @@ func (d *Devbox) RestartServices(ctx context.Context, serviceNames ...string) er

// TODO: Restart with no services should restart the _currently running_ services. This means we should get the list of running services from the process-compose, then restart them all.

svcSet, err := d.Services()
svcSet, err := d.Services("")
if err != nil {
return err
}
Expand All @@ -656,7 +656,7 @@ func (d *Devbox) StartProcessManager(
background bool,
processComposeFileOrDir string,
) error {
svcs, err := d.Services()
svcs, err := d.Services(processComposeFileOrDir)
if err != nil {
return err
}
Expand Down Expand Up @@ -699,13 +699,14 @@ func (d *Devbox) StartProcessManager(

// Start the process manager

fmt.Printf("Starting with File or Dir: %s\n", processComposeFileOrDir)
return services.StartProcessManager(
ctx,
d.writer,
requestedServices,
svcs,
d.projectDir,
processComposePath, processComposeFileOrDir,
processComposePath,
background,
)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/services/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"go.jetpack.io/devbox/internal/cuecfg"
)

func FromUserProcessCompose(projectDir string) Services {
processComposeYaml := lookupProcessCompose(projectDir, "")
func FromUserProcessCompose(projectDir string, userProcessCompose string) Services {
processComposeYaml := lookupProcessCompose(projectDir, userProcessCompose)
if processComposeYaml == "" {
return nil
}
Expand Down
2 changes: 0 additions & 2 deletions internal/services/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,9 @@ func StartProcessManager(
availableServices Services,
projectDir string,
processComposeBinPath string,
processComposeFilePath string,
processComposeBackground bool,
) error {
// Check if process-compose is already running

if ProcessManagerIsRunning(projectDir) {
return fmt.Errorf("process-compose is already running. To stop it, run `devbox services stop`")
}
Expand Down

0 comments on commit 5155490

Please sign in to comment.