func StartMesosphereApp(acfg apps.AppConfig, cloudName, cloudURI string) error { // func StartMesosphereApp(app gomarathon.Application, host string) error { dock_list, err := apps.GetAppDockerList("app", acfg) if err != nil { return err } var dock_opts []*apps.DockerOptions for _, dock_name := range dock_list { dopts, err := apps.ReadDockerOpts(dock_name, acfg) if err != nil { return err } fmt.Printf("%+v\n\n", dopts) dock_opts = append(dock_opts, &dopts) } apps.ReverseDockerList(dock_opts) for _, dopts := range dock_opts { err = StartMesosphereDocker(dopts, acfg, cloudName, cloudURI) if err != nil { return err } } return nil }
func db_fix(c *cli.Context) { if len(c.Args()) != 0 { fmt.Println("Error: bad args to 'db fix' !!!") cli.ShowSubcommandHelp(c) return } opts, err := apps.ReadDockerOpts("flask", APPCFG) if err != nil { fmt.Println("while getting docker options for: flask\n" + err.Error()) return } apps.PrepDocker(&opts, APPCFG) opts.Name = "dbfix." + opts.CreateOpts.Config.Domainname opts.CreateOpts.Name = opts.Name opts.CreateOpts.Config.Hostname = "dbfix" opts.CreateOpts.Config.ExposedPorts = nil opts.StartOpts.PortBindings = nil // printDockerOpts(opts) client, err := docker.NewClient(ZAHACONFIG.DockerHost) if err != nil { fmt.Println("while getting docker client: \n" + err.Error()) return } // setup the command cmd_n_args := []string{ "/sbin/my_init", "python", "/src/run.py", "dbfix", } fmt.Println("db fix: ", cmd_n_args) opts.CreateOpts.Config.Cmd = cmd_n_args // run the docker err = apps.StartDocker(&opts) if err != nil { fmt.Println("while init'n DB\n" + err.Error()) return } // wait for the docker to exit done := false exit := 0 for !done { dock, err := client.InspectContainer(opts.Name) if err != nil { fmt.Println("while inspecting container: ", opts.Name, "\n"+err.Error()) return } else if !dock.State.Running { exit = dock.State.ExitCode if exit != 0 { fmt.Printf("%v %v", dock.State.ExitCode, dock.State.Error) return } break } } // remove docker err = apps.RemoveDocker(opts.Name) if err != nil { fmt.Println("while removing container: ", opts.Name, "\n"+err.Error()) return } }