mirror of
https://github.com/docker/compose.git
synced 2025-05-29 19:00:13 +02:00
use project we just created to start services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
7fea9f7e8b
commit
db698562a9
@ -204,6 +204,7 @@ func runUp(ctx context.Context, backend api.Service, createOptions createOptions
|
|||||||
return backend.Up(ctx, project, api.UpOptions{
|
return backend.Up(ctx, project, api.UpOptions{
|
||||||
Create: create,
|
Create: create,
|
||||||
Start: api.StartOptions{
|
Start: api.StartOptions{
|
||||||
|
Project: project,
|
||||||
Attach: consumer,
|
Attach: consumer,
|
||||||
AttachTo: attachTo,
|
AttachTo: attachTo,
|
||||||
ExitCodeFrom: upOptions.exitCodeFrom,
|
ExitCodeFrom: upOptions.exitCodeFrom,
|
||||||
|
@ -117,6 +117,8 @@ type CreateOptions struct {
|
|||||||
|
|
||||||
// StartOptions group options of the Start API
|
// StartOptions group options of the Start API
|
||||||
type StartOptions struct {
|
type StartOptions struct {
|
||||||
|
// Project is the compose project used to define this app. Might be nil if user ran `start` just with project name
|
||||||
|
Project *types.Project
|
||||||
// Attach to container and forward logs if not nil
|
// Attach to container and forward logs if not nil
|
||||||
Attach LogConsumer
|
Attach LogConsumer
|
||||||
// AttachTo set the services to attach to
|
// AttachTo set the services to attach to
|
||||||
|
@ -35,15 +35,18 @@ func (s *composeService) Start(ctx context.Context, projectName string, options
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) start(ctx context.Context, projectName string, options api.StartOptions, listener api.ContainerEventListener) error {
|
func (s *composeService) start(ctx context.Context, projectName string, options api.StartOptions, listener api.ContainerEventListener) error {
|
||||||
var containers Containers
|
project := options.Project
|
||||||
containers, err := s.getContainers(ctx, projectName, oneOffExclude, true)
|
if project == nil {
|
||||||
if err != nil {
|
var containers Containers
|
||||||
return err
|
containers, err := s.getContainers(ctx, projectName, oneOffExclude, true)
|
||||||
}
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
project, err := s.projectFromName(containers, projectName, options.AttachTo...)
|
project, err = s.projectFromName(containers, projectName, options.AttachTo...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eg, ctx := errgroup.WithContext(ctx)
|
eg, ctx := errgroup.WithContext(ctx)
|
||||||
@ -60,7 +63,7 @@ func (s *composeService) start(ctx context.Context, projectName string, options
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
err = InDependencyOrder(ctx, project, func(c context.Context, name string) error {
|
err := InDependencyOrder(ctx, project, func(c context.Context, name string) error {
|
||||||
service, err := project.GetService(name)
|
service, err := project.GetService(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user