func ProjectUp(p project.APIProject, c *cli.Context) error { if err := p.Create(context.Background(), options.Create{}, c.Args()...); err != nil { return err } if err := p.Up(context.Background(), options.Up{}, c.Args()...); err != nil { return err } if !c.Bool("d") { p.Log(context.Background(), true) // wait forever <-make(chan interface{}) } return nil }
// ProjectUp brings all services up. func ProjectUp(p project.APIProject, c *cli.Context) error { options := options.Up{ Create: options.Create{ NoRecreate: c.Bool("no-recreate"), ForceRecreate: c.Bool("force-recreate"), NoBuild: c.Bool("no-build"), ForceBuild: c.Bool("build"), }, } ctx, cancelFun := context.WithCancel(context.Background()) err := p.Up(ctx, options, c.Args()...) if err != nil { return cli.NewExitError(err.Error(), 1) } if !c.Bool("d") { signalChan := make(chan os.Signal, 1) cleanupDone := make(chan bool) signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM) errChan := make(chan error) go func() { errChan <- p.Log(ctx, true, c.Args()...) }() go func() { select { case <-signalChan: fmt.Printf("\nGracefully stopping...\n") cancelFun() ProjectStop(p, c) cleanupDone <- true case err := <-errChan: if err != nil { logrus.Fatal(err) } cleanupDone <- true } }() <-cleanupDone return nil } return nil }