Skip to content

Commit dd33895

Browse files
committed
Lint + comments and helpful output
1 parent 761593d commit dd33895

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

internal/boxcli/services.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ func servicesCmd(persistentPreRunE ...cobraFunc) *cobra.Command {
142142
}
143143

144144
func attachServices(cmd *cobra.Command, flags servicesCmdFlags) error {
145-
146145
box, err := devbox.Open(&devopt.Opts{
147146
Dir: flags.config.path,
148147
Environment: flags.config.environment,

internal/devbox/services.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ func (d *Devbox) AttachToProcessManager(ctx context.Context) error {
193193
BinPath: processComposeBinPath,
194194
},
195195
)
196-
197196
}
198197

199198
func (d *Devbox) StartProcessManager(

internal/services/manager.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func StartProcessManager(
159159
if processComposeConfig.Background {
160160
flags = append(flags, "-t=false")
161161
cmd := exec.Command(processComposeConfig.BinPath, flags...)
162-
return runProcessManagerInBackground(cmd, config, port, projectDir)
162+
return runProcessManagerInBackground(cmd, config, port, projectDir, w)
163163
}
164164

165165
cmd := exec.Command(processComposeConfig.BinPath, flags...)
@@ -206,7 +206,7 @@ func runProcessManagerInForeground(cmd *exec.Cmd, config *globalProcessComposeCo
206206
return writeGlobalProcessComposeJSON(config, configFile)
207207
}
208208

209-
func runProcessManagerInBackground(cmd *exec.Cmd, config *globalProcessComposeConfig, port int, projectDir string) error {
209+
func runProcessManagerInBackground(cmd *exec.Cmd, config *globalProcessComposeConfig, port int, projectDir string, w io.Writer) error {
210210
logdir := filepath.Join(projectDir, processComposeLogfile)
211211
logfile, err := os.OpenFile(logdir, os.O_CREATE|os.O_WRONLY|os.O_APPEND|os.O_TRUNC, 0o664)
212212
if err != nil {
@@ -216,6 +216,8 @@ func runProcessManagerInBackground(cmd *exec.Cmd, config *globalProcessComposeCo
216216
cmd.Stdout = logfile
217217
cmd.Stderr = logfile
218218

219+
// These attributes set the process group ID to the process ID of process-compose
220+
// Starting in it's own process group means it won't be terminated if the shell crashes
219221
cmd.SysProcAttr = &syscall.SysProcAttr{
220222
Setpgid: true,
221223
Pgid: 0,
@@ -225,6 +227,9 @@ func runProcessManagerInBackground(cmd *exec.Cmd, config *globalProcessComposeCo
225227
return fmt.Errorf("failed to start process-compose: %w", err)
226228
}
227229

230+
fmt.Fprintf(w, "Process-compose is now running on port %d\n",port)
231+
fmt.Fprintf(w, "To stop your services, run `devbox services stop`\n")
232+
228233
projectConfig := instance{
229234
Pid: cmd.Process.Pid,
230235
Port: port,
@@ -309,7 +314,7 @@ func AttachToProcessManager(ctx context.Context, w io.Writer, projectDir string,
309314

310315
project, ok := config.Instances[projectDir]
311316
if !ok {
312-
return fmt.Errorf("Process-compose is not running for this project. To start it, run `devbox services up`")
317+
return fmt.Errorf("process-compose is not running for this project. To start it, run `devbox services up`")
313318
}
314319

315320
flags := []string{"attach", "-p", strconv.Itoa(project.Port)}

0 commit comments

Comments
 (0)