// CmdStart start cmdFile.
1932
func (c *Cmd) CmdStart() error {

	var err error

	// CmdLine check
	if c.CmdLine != "" && c.Cmd == nil {
		parseCmd, err := shellwords.Parse(c.CmdLine)
		if err != nil {
			return err
		}
		c.Cmd = exec.Command(parseCmd[0], parseCmd[1:]...)
	}
	if c.CmdLine == "" {
		c.CmdLine = strings.Join(c.Cmd.Args, " ")
	}

	var stdoutPipe, stderrPipe io.ReadCloser

	if !c.stdoutPipe {
		stdoutPipe, err = c.Cmd.StdoutPipe()
		if err != nil {
			return err
		}
	}
	if !c.stderrPipe {
		stderrPipe, err = c.Cmd.StderrPipe()
		if err != nil {
			return err
		}
	}

	// Start command.
	err = c.Cmd.Start()
	if err != nil {
		c.ExitError = err
		c.GetExitCode()
		return err
	}

	scanWrite := func(c *Cmd, r io.ReadCloser, w io.Writer, enc *encoding.Decoder, print bool) {
		if r == nil {
			return
		}
		c.Wg.Add(1)
		go func() {
			defer c.Wg.Done()
			if enc == nil {
				ScanWrite(bufio.NewScanner(r), w, print)
			} else {
				ScanWrite(bufio.NewScanner(transform.NewReader(r, enc)), w, print)
			}
		}()
	}

	scanWrite(c, stdoutPipe, &c.Stdout, c.StdoutEnc, c.StdoutPrint)
	scanWrite(c, stderrPipe, &c.Stderr, c.StderrEnc, c.StderrPrint)

	return nil
}
423363
func (s *Stdout) Start() error {
	if os.Stdout == nil {
		return errors.New("stdout is not available")
	}
	return nil
}
854813
func (s *ServerRPC) PodStart(ctx context.Context, req *types.PodStartRequest) (*types.PodStartResponse, error) {
	err := s.daemon.StartPod(req.PodID)
	if err != nil {
		return nil, err
	}

	return &types.PodStartResponse{}, nil
}
1184056
func Start(sockFile string, c *cli.Context) error {
	var err error

	if err = daemonEnvironmentSetup(c); err != nil {
		return err
	}
	defer environmentCleanup()

	root := c.String("root")
	s := &daemon{
		ConvoyDrivers: make(map[string]ConvoyDriver),
	}
	config := &daemonConfig{
		Root: root,
	}

	ignoreCfgFile := c.Bool("ignore-config-file")
	exists := false
	if !ignoreCfgFile {
		exists, err = util.ObjectExists(config)
		if err != nil {
			return err
		}
	}

	if exists {
		log.Debug("Found existing config. Ignoring command line opts, loading config from ", root)
		if err := util.ObjectLoad(config); err != nil {
			return err
		}
	} else {
		fd := c.String("mnt-ns")
		if fd != "" {
			if _, err := os.Stat(fd); err != nil {
				return fmt.Errorf("Cannot find mount namespace fd %v", fd)
			}
			config.MountNamespaceFD = fd
		}

		driverList := c.StringSlice("drivers")
		if len(driverList) == 0 {
			return fmt.Errorf("Missing or invalid parameters")
		}
		log.Debug("Creating config at ", root)

		config.DriverList = driverList
		config.DefaultDriver = driverList[0]
		config.IgnoreDockerDelete = c.Bool("ignore-docker-delete")
		config.CreateOnDockerMount = c.Bool("create-on-docker-mount")
		config.CmdTimeout = c.String("cmd-timeout")
	}

	s.daemonConfig = *config

	if err := util.InitMountNamespace(s.MountNamespaceFD); err != nil {
		return err
	}

	util.InitTimeout(config.CmdTimeout)

	// driverOpts would be ignored by Convoy Drivers if config already exists
	driverOpts := util.SliceToMap(c.StringSlice("driver-opts"))
	if err := s.initDrivers(driverOpts); err != nil {
		return err
	}
	if err := s.finializeInitialization(); err != nil {
		return err
	}
	if err := util.ObjectSave(config); err != nil {
		return err
	}

	s.Router = createRouter(s)

	if err := util.MkdirIfNotExists(filepath.Dir(sockFile)); err != nil {
		return err
	}
	// This should be safe because lock file prevent starting daemon twice
	if _, err := os.Stat(sockFile); err == nil {
		log.Warnf("Remove previous sockfile at %v", sockFile)
		if err := os.Remove(sockFile); err != nil {
			return err
		}
	}

	l, err := net.Listen("unix", sockFile)
	if err != nil {
		fmt.Println("listen err", err)
		return err
	}
	defer l.Close()

	sigs := make(chan os.Signal, 1)
	done := make(chan bool, 1)
	signal.Notify(sigs, os.Interrupt, os.Kill, syscall.SIGTERM)
	go func() {
		sig := <-sigs
		fmt.Printf("Caught signal %s: shutting down.\n", sig)
		done <- true
	}()

	go func() {
		err = http.Serve(l, s.Router)
		if err != nil {
			log.Error("http server error", err.Error())
		}
		done <- true
	}()

	<-done
	return nil
}
4260
func runStart(cmd *cobra.Command, args []string) {
	console.OutStyle("happy", "minikube %s on %s (%s)", version.GetVersion(), runtime.GOOS, runtime.GOARCH)
	validateConfig()

	oldConfig, err := cfg.Load()
	if err != nil && !os.IsNotExist(err) {
		exit.WithCode(exit.Data, "Unable to load config: %v", err)
	}
	k8sVersion, isUpgrade := validateKubernetesVersions(oldConfig)
	config, err := generateConfig(cmd, k8sVersion)
	if err != nil {
		exit.WithError("Failed to generate config", err)
	}

	// For non-"none", the ISO is required to boot, so block until it is downloaded
	if viper.GetString(vmDriver) != constants.DriverNone {
		if err := cluster.CacheISO(config.MachineConfig); err != nil {
			exit.WithError("Failed to cache ISO", err)
		}
	} else {
		// With "none", images are persistently stored in Docker, so internal caching isn't necessary.
		viper.Set(cacheImages, false)
	}

	// Now that the ISO is downloaded, pull images in the background while the VM boots.
	var cacheGroup errgroup.Group
	beginCacheImages(&cacheGroup, k8sVersion)

	// Abstraction leakage alert: startHost requires the config to be saved, to satistfy pkg/provision/buildroot.
	// Hence, saveConfig must be called before startHost, and again afterwards when we know the IP.
	if err := saveConfig(config); err != nil {
		exit.WithError("Failed to save config", err)
	}

	m, err := machine.NewAPIClient()
	if err != nil {
		exit.WithError("Failed to get machine client", err)
	}

	// If --download-only, complete the remaining downloads and exit.
	if viper.GetBool(downloadOnly) {
		if err := doCacheBinaries(k8sVersion); err != nil {
			exit.WithError("Failed to cache binaries", err)
		}
		waitCacheImages(&cacheGroup)
		if err := CacheImagesInConfigFile(); err != nil {
			exit.WithError("Failed to cache images", err)
		}
		console.OutStyle("check", "Download complete!")
		return
	}

	host, preexisting := startHost(m, config.MachineConfig)

	ip := validateNetwork(host)
	// Save IP to configuration file for subsequent use
	config.KubernetesConfig.NodeIP = ip
	if err := saveConfig(config); err != nil {
		exit.WithError("Failed to save config", err)
	}
	runner, err := machine.CommandRunner(host)
	if err != nil {
		exit.WithError("Failed to get command runner", err)
	}

	cr := configureRuntimes(host, runner)

	// prepareHostEnvironment uses the downloaded images, so we need to wait for background task completion.
	waitCacheImages(&cacheGroup)

	bs := prepareHostEnvironment(m, config.KubernetesConfig)

	// The kube config must be update must come before bootstrapping, otherwise health checks may use a stale IP
	kubeconfig := updateKubeConfig(host, &config)
	bootstrapCluster(bs, cr, runner, config.KubernetesConfig, preexisting, isUpgrade)

	apiserverPort := config.KubernetesConfig.NodePort
	validateCluster(bs, cr, runner, ip, apiserverPort)
	configureMounts()
	if err = LoadCachedImagesInConfigFile(); err != nil {
		console.Failure("Unable to load cached images from config file.")
	}

	if config.MachineConfig.VMDriver == constants.DriverNone {
		console.OutStyle("starting-none", "Configuring local host environment ...")
		prepareNone()
	}

	showKubectlConnectInfo(kubeconfig)
	console.OutStyle("ready", "Done! Thank you for using minikube!")
}
530022
func (s *SearchInput) SetStart(v int64) *SearchInput {
	s.Start = &v
	return s
}
1108120
func (c *Cmd) CmdRun() error {

	var err error

	err = c.CmdStart()
	if err != nil {
		return err
	}

	c.CmdWait()
	return nil
}
1134144
func (WindowsStrategy) start(ctx context.Context, path string) error {
	cmd := exec.Command(path)
	cmd.SysProcAttr = &syscall.SysProcAttr{
		// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863.aspx
		// CREATE_NEW_PROCESS_GROUP: 	0x200
		// DETACHED_PROCESS: 		0x008
		CreationFlags: 0x200 | 0x8,
	}
	return cmd.Start()
}
1097364
func ExecCmdDir(dir, cmdName string, args ...string) (string, string, error) {
	bufOut, bufErr, err := ExecCmdDirBytes(dir, cmdName, args...)
	return string(bufOut), string(bufErr), err
}
748245
func Start(cdyfile Input) (*Instance, error) {
	inst := &Instance{serverType: cdyfile.ServerType(), wg: new(sync.WaitGroup), Storage: make(map[interface{}]interface{})}
	err := startWithListenerFds(cdyfile, inst, nil)
	if err != nil {
		return inst, err
	}
	signalSuccessToParent()
	if pidErr := writePidFile(); pidErr != nil {
		log.Printf("[ERROR] Could not write pidfile: %v", pidErr)
	}

	// Execute instantiation events
	EmitEvent(InstanceStartupEvent, inst)

	return inst, nil
}
627369
func (c *Gcd) StartProcessCustom(cmd *exec.Cmd, userDir, port string) error {
	c.port = port
	c.addr = fmt.Sprintf("%s:%s", c.host, c.port)
	c.profileDir = userDir
	c.apiEndpoint = fmt.Sprintf("http://%s/json", c.addr)
	c.chromeCmd = cmd

	return c.startProcess()
}
1351343
func (h *BytesRefHash) ByteStart(bytesId int) int {
	assert2(h.bytesStart != nil, "bytesStart is null - not initialized")
	assert2(bytesId >= 0 && bytesId <= h.count, "%v", bytesId)
	return h.bytesStart[bytesId]
}
1063086
func (s *DescribeReservationOutput) SetStart(v string) *DescribeReservationOutput {
	s.Start = &v
	return s
}
202490
func (s *TimePeriod) SetStart(v time.Time) *TimePeriod {
	s.Start = &v
	return s
}
1199143
func (s *Service) StartCommands() ([]string, error) {
	name := s.Name()
	cmdList := []string{
		cmds.start(name),
	}
	return cmdList, nil
}
100238
func runStart(dockerCli command.Cli, opts *startOptions) error {
	ctx, cancelFun := context.WithCancel(context.Background())
	defer cancelFun()

	if opts.attach || opts.openStdin {
		// We're going to attach to a container.
		// 1. Ensure we only have one container.
		if len(opts.containers) > 1 {
			return errors.New("you cannot start and attach multiple containers at once")
		}

		// 2. Attach to the container.
		container := opts.containers[0]
		c, err := dockerCli.Client().ContainerInspect(ctx, container)
		if err != nil {
			return err
		}

		// We always use c.ID instead of container to maintain consistency during `docker start`
		if !c.Config.Tty {
			sigc := ForwardAllSignals(ctx, dockerCli, c.ID)
			defer signal.StopCatch(sigc)
		}

		if opts.detachKeys != "" {
			dockerCli.ConfigFile().DetachKeys = opts.detachKeys
		}

		options := types.ContainerAttachOptions{
			Stream:     true,
			Stdin:      opts.openStdin && c.Config.OpenStdin,
			Stdout:     true,
			Stderr:     true,
			DetachKeys: dockerCli.ConfigFile().DetachKeys,
		}

		var in io.ReadCloser

		if options.Stdin {
			in = dockerCli.In()
		}

		resp, errAttach := dockerCli.Client().ContainerAttach(ctx, c.ID, options)
		if errAttach != nil && errAttach != httputil.ErrPersistEOF {
			// ContainerAttach return an ErrPersistEOF (connection closed)
			// means server met an error and already put it in Hijacked connection,
			// we would keep the error and read the detailed error message from hijacked connection
			return errAttach
		}
		defer resp.Close()

		cErr := make(chan error, 1)

		go func() {
			cErr <- func() error {
				streamer := hijackedIOStreamer{
					streams:      dockerCli,
					inputStream:  in,
					outputStream: dockerCli.Out(),
					errorStream:  dockerCli.Err(),
					resp:         resp,
					tty:          c.Config.Tty,
					detachKeys:   options.DetachKeys,
				}

				errHijack := streamer.stream(ctx)
				if errHijack == nil {
					return errAttach
				}
				return errHijack
			}()
		}()

		// 3. We should open a channel for receiving status code of the container
		// no matter it's detached, removed on daemon side(--rm) or exit normally.
		statusChan := waitExitOrRemoved(ctx, dockerCli, c.ID, c.HostConfig.AutoRemove)
		startOptions := types.ContainerStartOptions{
			CheckpointID:  opts.checkpoint,
			CheckpointDir: opts.checkpointDir,
		}

		// 4. Start the container.
		if err := dockerCli.Client().ContainerStart(ctx, c.ID, startOptions); err != nil {
			cancelFun()
			<-cErr
			if c.HostConfig.AutoRemove {
				// wait container to be removed
				<-statusChan
			}
			return err
		}

		// 5. Wait for attachment to break.
		if c.Config.Tty && dockerCli.Out().IsTerminal() {
			if err := MonitorTtySize(ctx, dockerCli, c.ID, false); err != nil {
				fmt.Fprintln(dockerCli.Err(), "Error monitoring TTY size:", err)
			}
		}
		if attachErr := <-cErr; attachErr != nil {
			if _, ok := err.(term.EscapeError); ok {
				// The user entered the detach escape sequence.
				return nil
			}
			return attachErr
		}

		if status := <-statusChan; status != 0 {
			return cli.StatusError{StatusCode: status}
		}
	} else if opts.checkpoint != "" {
		if len(opts.containers) > 1 {
			return errors.New("you cannot restore multiple containers at once")
		}
		container := opts.containers[0]
		startOptions := types.ContainerStartOptions{
			CheckpointID:  opts.checkpoint,
			CheckpointDir: opts.checkpointDir,
		}
		return dockerCli.Client().ContainerStart(ctx, container, startOptions)

	} else {
		// We're not going to attach to anything.
		// Start as many containers as we want.
		return startContainersWithoutAttachments(ctx, dockerCli, opts.containers)
	}

	return nil
}
276000
func (s *Reservation) SetStart(v string) *Reservation {
	s.Start = &v
	return s
}