From e0ddaf2b5abaf12384c48d30656a39896d0dd004 Mon Sep 17 00:00:00 2001 From: Andrii Klymiuk Date: Wed, 5 Oct 2022 22:00:04 +0300 Subject: [PATCH] Added checking docker status before db run --- cmd/run.go | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index dfbd98b..b1d8674 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -67,13 +67,31 @@ func runRun(cmd *cobra.Command, args []string) { CreateDatabaseServices(corgi.DatabaseServices) + runDatabaseServices(cmd, corgi.DatabaseServices) + + generateEnvForServices(corgi) + + for _, service := range corgi.Services { + servicesWaitGroup.Add(1) + go runService(service, cmd) + } + servicesWaitGroup.Wait() +} + +func runDatabaseServices(cmd *cobra.Command, databaseServices []utils.DatabaseService) { isSeed, err := cmd.Flags().GetBool("seed") if err != nil { return } + err = utils.DockerInit() + if err != nil { + fmt.Println(err) + return + } + if isSeed { - for _, dbService := range corgi.DatabaseServices { + for _, dbService := range databaseServices { if (dbService.SeedFromDb == utils.SeedDbSource{}) { continue } @@ -89,14 +107,6 @@ func runRun(cmd *cobra.Command, args []string) { } utils.ExecuteForEachService("up") - - generateEnvForServices(corgi) - - for _, service := range corgi.Services { - servicesWaitGroup.Add(1) - go runService(service, cmd) - } - servicesWaitGroup.Wait() } func runService(service utils.Service, cobraCmd *cobra.Command) {