MCPcopy Index your code
hub / github.com/ddev/ddev / StartOptionalProfiles

Method StartOptionalProfiles

pkg/ddevapp/ddevapp.go:2150–2202  ·  view source on GitHub ↗

StartOptionalProfiles starts services in the named compose profile(s) The profiles can be a comma-separated list

(profiles []string)

Source from the content-addressed store, hash-verified

2148// StartOptionalProfiles starts services in the named compose profile(s)
2149// The profiles can be a comma-separated list
2150func (app *DdevApp) StartOptionalProfiles(profiles []string) error {
2151 var err error
2152 if status, _ := app.SiteStatus(); status != SiteRunning {
2153 err = app.Start()
2154 if err != nil {
2155 return err
2156 }
2157 }
2158
2159 _, stderr, err := dockerutil.ComposeCmd(&dockerutil.ComposeCmdOpts{
2160 ComposeFiles: []string{app.DockerComposeFullRenderedYAMLPath()},
2161 Profiles: profiles,
2162 Action: []string{"up", "-d"},
2163 })
2164
2165 if err != nil {
2166 util.Warning("Failed to start optional compose profiles '%s': %v, stderr='%s'", profiles, err, stderr)
2167 return err
2168 }
2169
2170 if !IsRouterDisabled(app) {
2171 util.Debug("Starting %s if necessary...", nodeps.RouterContainer)
2172 err = StartDdevRouter()
2173 if err != nil {
2174 return err
2175 }
2176 }
2177
2178 // Get the actual service names from the profiles
2179 var serviceNames []string
2180 if app.ComposeYaml != nil && app.ComposeYaml.Services != nil {
2181 for serviceName, service := range app.ComposeYaml.Services {
2182 for _, profile := range profiles {
2183 if slices.Contains(service.Profiles, profile) {
2184 serviceNames = append(serviceNames, serviceName)
2185 break
2186 }
2187 }
2188 }
2189 }
2190
2191 if len(serviceNames) > 0 {
2192 wait := output.StartWait(fmt.Sprintf("Waiting for containers to become ready: %v", serviceNames))
2193 err = app.Wait(serviceNames)
2194 wait.Complete(err)
2195 if err != nil {
2196 return err
2197 }
2198 }
2199 util.Success("Started optional compose profiles '%s'", strings.Join(profiles, ","))
2200
2201 return nil
2202}
2203
2204// Restart does a Stop() and a Start
2205func (app *DdevApp) Restart() error {

Callers 4

XHGuiSetupFunction · 0.80
start.goFile · 0.80

Calls 12

SiteStatusMethod · 0.95
StartMethod · 0.95
WaitMethod · 0.95
ComposeCmdFunction · 0.92
WarningFunction · 0.92
DebugFunction · 0.92
StartWaitFunction · 0.92
SuccessFunction · 0.92
IsRouterDisabledFunction · 0.85
StartDdevRouterFunction · 0.85
CompleteMethod · 0.80

Tested by 2