// autostart configures the given Swarming bot code to be executed on startup
// for the given user, then starts the Swarming bot process.
// Implements PlatformStrategy.
492346
func (*UpstartStrategy) autostart(c context.Context, path, user string) error {
	subs := map[string]string{
		"BotCode": path,
		"User":    user,
	}
	s, err := substitute(c, string(GetAsset(upstartTmpl)), subs)
	if err != nil {
		return errors.Annotate(err, "failed to prepare template %q", upstartTmpl).Err()
	}

	logging.Infof(c, "installing: %s", upstartCfg)
	// 0644 allows the upstart config to be read by all users.
	// Useful when SSHing to the instance.
	if err := ioutil.WriteFile(upstartCfg, []byte(s), 0644); err != nil {
		return errors.Annotate(err, "failed to write: %s", upstartCfg).Err()
	}

	logging.Infof(c, "starting %q", upstartSrv)
	if err := exec.Command("initctl", "start", upstartSrv).Run(); err != nil {
		return errors.Annotate(err, "failed to start service %q", upstartSrv).Err()
	}
	return nil
}
1023557
func (_m *APIClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
	ret := _m.Called(ctx, req)

	var r0 string
	if rf, ok := ret.Get(0).(func(context.Context, swarm.InitRequest) string); ok {
		r0 = rf(ctx, req)
	} else {
		r0 = ret.Get(0).(string)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, swarm.InitRequest) error); ok {
		r1 = rf(ctx, req)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
899574
func (o *LaunchSpecification) SetStartupScript(v *string) *LaunchSpecification {
	if o.StartupScript = v; o.StartupScript == nil {
		o.nullFields = append(o.nullFields, "StartupScript")
	}
	return o
}
439393
func (_m *APIClient) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error {
	ret := _m.Called(ctx, execID, config)

	var r0 error
	if rf, ok := ret.Get(0).(func(context.Context, string, types.ExecStartCheck) error); ok {
		r0 = rf(ctx, execID, config)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
246582
func Start() {
	connect()
	go startBatcher(commonBatchStream)

	for i := range registry {
		debug("starting", registry[i])
		go registry[i].StartLoop()
	}
}
883364
func (m *MockSwarmAPIClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
	ret := m.ctrl.Call(m, "SwarmInit", ctx, req)
	ret0, _ := ret[0].(string)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
731155
func (memR *MempoolReactor) OnStart() error {
	if !memR.config.Broadcast {
		memR.Logger.Info("Tx broadcasting is disabled")
	}
	return nil
}
986623
func (s *Server) OnStartupComplete() {
	if Quiet {
		return
	}

	out := startUpZones("", s.Addr, s.zones)
	if out != "" {
		fmt.Print(out)
	}
	return
}
189163
func (m *Module) Init(c *service.Config) {
	c.Start = func() {
		for _, p := range m.oauthConfigs {
			m.register(p)
		}
	}
}
189938
func (kc *KubeClient) StartBot(ip string, botID int32, proj *models.Project, game *models.Game) (*api.Pod, error) {
	pod := createBotPod(ip, botID, proj, game)
	log.Printf("Starting bot! Spec:\n%v", pod)
	return kc.client.Pods(api.NamespaceDefault).Create(pod)
}
1160205
func init() {
	graphdriver.Register("windowsfilter", InitFilter)
	// DOCKER_WINDOWSFILTER_NOREEXEC allows for inline processing which makes
	// debugging issues in the re-exec codepath significantly easier.
	if os.Getenv("DOCKER_WINDOWSFILTER_NOREEXEC") != "" {
		logrus.Warnf("WindowsGraphDriver is set to not re-exec. This is intended for debugging purposes only.")
		noreexec = true
	} else {
		reexec.Register("docker-windows-write-layer", writeLayerReexec)
	}
}
735543
func StartBee(bee BeeConfig) *BeeInterface {
	b := NewBeeInstance(bee)

	(*b).Start()
	go func(mod *BeeInterface) {
		startBee(mod, 0)
	}(b)

	return b
}
393311
func InstallAndStart(svc ServiceActions) error {
	logger.Infof("Installing and starting service %+v", svc)
	if err := svc.Install(); err != nil {
		return errors.Trace(err)
	}

	// For various reasons the init system may take a short time to
	// realise that the service has been installed.
	var err error
	for attempt := installStartRetryAttempts.Start(); attempt.Next(); {
		if err != nil {
			logger.Errorf("retrying start request (%v)", errors.Cause(err))
		}
		// we attempt restart if the service is running in case daemon parameters
		// have changed, if its not running a regular start will happen.
		if err = ManuallyRestart(svc); err == nil {
			logger.Debugf("started %v", svc)
			break
		}
	}
	return errors.Trace(err)
}
1000740
func (darwin *darwinRecord) Start() (string, error) {
	startAction := "Starting " + darwin.description + ":"

	if ok, err := checkPrivileges(); !ok {
		return startAction + failed, err
	}

	if !darwin.isInstalled() {
		return startAction + failed, ErrNotInstalled
	}

	if _, ok := darwin.checkRunning(); ok {
		return startAction + failed, ErrAlreadyRunning
	}

	if err := exec.Command("launchctl", "load", darwin.servicePath()).Run(); err != nil {
		return startAction + failed, err
	}

	return startAction + success, nil
}
1140151
func init() {
	// Root
	CommandLineOptions.Root = &cobra.Command{
		Use:           path.Base(os.Args[0]),
		Short:         "Sparta-powered AWS Lambda microservice",
		SilenceErrors: true,
	}
	CommandLineOptions.Root.PersistentFlags().BoolVarP(&OptionsGlobal.Noop, "noop",
		"n",
		false,
		"Dry-run behavior only (do not perform mutations)")
	CommandLineOptions.Root.PersistentFlags().StringVarP(&OptionsGlobal.LogLevel,
		"level",
		"l",
		"info",
		"Log level [panic, fatal, error, warn, info, debug]")
	CommandLineOptions.Root.PersistentFlags().StringVarP(&OptionsGlobal.LogFormat,
		"format",
		"f",
		"text",
		"Log format [text, json]")
	CommandLineOptions.Root.PersistentFlags().BoolVarP(&OptionsGlobal.TimeStamps,
		"timestamps",
		"z",
		false,
		"Include UTC timestamp log line prefix")
	CommandLineOptions.Root.PersistentFlags().StringVarP(&OptionsGlobal.BuildTags,
		"tags",
		"t",
		"",
		"Optional build tags for conditional compilation")
	// Make sure there's a place to put any linker flags
	CommandLineOptions.Root.PersistentFlags().StringVar(&OptionsGlobal.LinkerFlags,
		"ldflags",
		"",
		"Go linker string definition flags (https://golang.org/cmd/link/)")

	// Support disabling log colors for CLI friendliness
	CommandLineOptions.Root.PersistentFlags().BoolVarP(&OptionsGlobal.DisableColors,
		"nocolor",
		"",
		false,
		"Boolean flag to suppress colorized TTY output")

	// Version
	CommandLineOptions.Version = &cobra.Command{
		Use:          "version",
		Short:        "Display version information",
		Long:         `Displays the Sparta framework version `,
		SilenceUsage: true,
		Run: func(cmd *cobra.Command, args []string) {

		},
	}
	// Provision
	CommandLineOptions.Provision = &cobra.Command{
		Use:          "provision",
		Short:        "Provision service",
		Long:         `Provision the service (either create or update) via CloudFormation`,
		SilenceUsage: true,
	}
	CommandLineOptions.Provision.Flags().StringVarP(&optionsProvision.S3Bucket,
		"s3Bucket",
		"s",
		"",
		"S3 Bucket to use for Lambda source")
	CommandLineOptions.Provision.Flags().StringVarP(&optionsProvision.BuildID,
		"buildID",
		"i",
		"",
		"Optional BuildID to use")
	CommandLineOptions.Provision.Flags().StringVarP(&optionsProvision.PipelineTrigger,
		"codePipelinePackage",
		"p",
		"",
		"Name of CodePipeline package that includes cloudformation.json Template and ZIP config files")
	CommandLineOptions.Provision.Flags().BoolVarP(&optionsProvision.InPlace,
		"inplace",
		"c",
		false,
		"If the provision operation results in *only* function updates, bypass CloudFormation")

	// Delete
	CommandLineOptions.Delete = &cobra.Command{
		Use:          "delete",
		Short:        "Delete service",
		Long:         `Ensure service is successfully deleted`,
		SilenceUsage: true,
	}

	// Execute
	CommandLineOptions.Execute = &cobra.Command{
		Use:          "execute",
		Short:        "Start the application and begin handling events",
		Long:         `Start the application and begin handling events`,
		SilenceUsage: true,
	}

	// Describe
	CommandLineOptions.Describe = &cobra.Command{
		Use:          "describe",
		Short:        "Describe service",
		Long:         `Produce an HTML report of the service`,
		SilenceUsage: true,
	}
	CommandLineOptions.Describe.Flags().StringVarP(&optionsDescribe.OutputFile,
		"out",
		"o",
		"",
		"Output file for HTML description")
	CommandLineOptions.Describe.Flags().StringVarP(&optionsDescribe.S3Bucket,
		"s3Bucket",
		"s",
		"",
		"S3 Bucket to use for Lambda source")

	// Explore
	CommandLineOptions.Explore = &cobra.Command{
		Use:          "explore",
		Short:        "Interactively explore a provisioned service",
		Long:         `Startup a local CLI GUI to explore and trigger your AWS service`,
		SilenceUsage: true,
	}

	// Profile
	CommandLineOptions.Profile = &cobra.Command{
		Use:          "profile",
		Short:        "Interactively examine service pprof output",
		Long:         `Startup a local pprof webserver to interrogate profiles snapshots on S3`,
		SilenceUsage: true,
	}
	CommandLineOptions.Profile.Flags().StringVarP(&optionsProfile.S3Bucket,
		"s3Bucket",
		"s",
		"",
		"S3 Bucket that stores lambda profile snapshots")
	CommandLineOptions.Profile.Flags().IntVarP(&optionsProfile.Port,
		"port",
		"p",
		8080,
		"Alternative port for `pprof` web UI (default=8080)")

	// Status
	CommandLineOptions.Status = &cobra.Command{
		Use:          "status",
		Short:        "Produce a report for a provisioned service",
		Long:         `Produce a report for a provisioned service`,
		SilenceUsage: true,
	}
	CommandLineOptions.Status.Flags().BoolVarP(&optionsStatus.Redact, "redact",
		"r",
		false,
		"Redact AWS Account ID from report")
}
198751
func (bcR *BlockchainReactor) OnStart() error {
	if bcR.fastSync {
		err := bcR.pool.Start()
		if err != nil {
			return err
		}
		go bcR.poolRoutine()
	}
	return nil
}
821999
func (c *Config) Init(prvKey *ecdsa.PrivateKey, nodeKey *ecdsa.PrivateKey) error {

	// create swarm dir and record key
	err := c.createAndSetPath(c.Path, prvKey)
	if err != nil {
		return fmt.Errorf("Error creating root swarm data directory: %v", err)
	}
	c.setKey(prvKey)

	// create the new enode record
	// signed with the ephemeral node key
	enodeParams := &network.EnodeParams{
		PrivateKey: prvKey,
		EnodeKey:   nodeKey,
		Lightnode:  c.LightNodeEnabled,
		Bootnode:   c.BootnodeMode,
	}
	c.Enode, err = network.NewEnode(enodeParams)
	if err != nil {
		return fmt.Errorf("Error creating enode: %v", err)
	}

	// initialize components that depend on the swarm instance's private key
	if c.SwapEnabled {
		c.Swap.Init(c.Contract, prvKey)
	}

	c.LocalStoreParams.Init(c.Path)
	c.LocalStoreParams.BaseKey = common.FromHex(c.BzzKey)

	c.Pss = c.Pss.WithPrivateKey(c.privateKey)
	return nil
}