(cmd *exec.Cmd, config *globalProcessComposeConfig, port int, projectDir string, w io.Writer)
| 172 | } |
| 173 | |
| 174 | func runProcessManagerInForeground(cmd *exec.Cmd, config *globalProcessComposeConfig, port int, projectDir string, w io.Writer) error { |
| 175 | cmd.Stdout = os.Stdout |
| 176 | cmd.Stderr = os.Stderr |
| 177 | if err := cmd.Start(); err != nil { |
| 178 | return fmt.Errorf("failed to start process-compose: %w", err) |
| 179 | } |
| 180 | |
| 181 | projectConfig := instance{ |
| 182 | Pid: cmd.Process.Pid, |
| 183 | Port: port, |
| 184 | } |
| 185 | |
| 186 | config.Instances[projectDir] = projectConfig |
| 187 | |
| 188 | err := writeGlobalProcessComposeJSON(config, config.File) |
| 189 | if err != nil { |
| 190 | return err |
| 191 | } |
| 192 | |
| 193 | // We're waiting now, so we can unlock the file |
| 194 | config.File.Close() |
| 195 | |
| 196 | err = cmd.Wait() |
| 197 | if err != nil { |
| 198 | if err.Error() == "exit status 1" { |
| 199 | fmt.Fprintf(w, "Process-compose was terminated remotely, %s\n", err.Error()) |
| 200 | return nil |
| 201 | } |
| 202 | return err |
| 203 | } |
| 204 | |
| 205 | configFile, err := openGlobalConfigFile() |
| 206 | if err != nil { |
| 207 | return err |
| 208 | } |
| 209 | |
| 210 | config = readGlobalProcessComposeJSON(configFile) |
| 211 | |
| 212 | delete(config.Instances, projectDir) |
| 213 | return writeGlobalProcessComposeJSON(config, configFile) |
| 214 | } |
| 215 | |
| 216 | func runProcessManagerInBackground(cmd *exec.Cmd, config *globalProcessComposeConfig, port int, projectDir string, w io.Writer) error { |
| 217 | logdir := filepath.Join(projectDir, processComposeLogfile) |
no test coverage detected