( w io.Writer, requestedServices []string, availableServices Services, projectDir string, processComposeConfig ProcessComposeOpts, )
| 105 | } |
| 106 | |
| 107 | func StartProcessManager( |
| 108 | w io.Writer, |
| 109 | requestedServices []string, |
| 110 | availableServices Services, |
| 111 | projectDir string, |
| 112 | processComposeConfig ProcessComposeOpts, |
| 113 | ) error { |
| 114 | // Check if process-compose is already running |
| 115 | if ProcessManagerIsRunning(projectDir) { |
| 116 | return fmt.Errorf("process-compose is already running. To stop it, run `devbox services stop`") |
| 117 | } |
| 118 | |
| 119 | // Get the file and lock it right at the start |
| 120 | |
| 121 | configFile, err := openGlobalConfigFile() |
| 122 | if err != nil { |
| 123 | return err |
| 124 | } |
| 125 | |
| 126 | defer configFile.Close() |
| 127 | |
| 128 | // Read the global config file |
| 129 | config := readGlobalProcessComposeJSON(configFile) |
| 130 | config.File = configFile |
| 131 | |
| 132 | port, err := selectPort(processComposeConfig.ProcessComposePort) |
| 133 | if err != nil { |
| 134 | return fmt.Errorf("failed to select port: %v", err) |
| 135 | } |
| 136 | |
| 137 | // Start building the process-compose command |
| 138 | flags := []string{"-p", strconv.Itoa(port)} |
| 139 | upCommand := []string{"up"} |
| 140 | |
| 141 | if len(requestedServices) > 0 { |
| 142 | flags = append(requestedServices, flags...) |
| 143 | flags = append(upCommand, flags...) |
| 144 | fmt.Fprintf(w, "Starting services: %s \n", strings.Join(requestedServices, ", ")) |
| 145 | } else { |
| 146 | services := []string{} |
| 147 | for k := range availableServices { |
| 148 | services = append(services, k) |
| 149 | } |
| 150 | fmt.Fprintf(w, "Starting all services: %s \n", strings.Join(services, ", ")) |
| 151 | } |
| 152 | |
| 153 | seenPCFiles := make(map[string]bool) |
| 154 | for _, s := range availableServices { |
| 155 | if !seenPCFiles[s.ProcessComposePath] { |
| 156 | // Only add -f flag if we haven't seen this file path before |
| 157 | flags = append(flags, "-f", s.ProcessComposePath) |
| 158 | seenPCFiles[s.ProcessComposePath] = true |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | flags = append(flags, processComposeConfig.ExtraFlags...) |
| 163 | |
| 164 | if processComposeConfig.Background { |
no test coverage detected