// StartAutogit launches autogit, and returns a function that should
// be called on shutdown.
499392
func StartAutogit(config libkbfs.Config, browserCacheSize int) func() {
	am := NewAutogitManager(config, browserCacheSize)
	rw := rootWrapper{am}
	config.AddRootNodeWrapper(rw.wrap)
	return am.Shutdown
}
906887
func (b *ButtonDriver) Start() (err error) {
	state := b.DefaultState
	go func() {
		for {
			newValue, err := b.connection.DigitalRead(b.Pin())
			if err != nil {
				b.Publish(Error, err)
			} else if newValue != state && newValue != -1 {
				state = newValue
				b.update(newValue)
			}
			select {
			case <-time.After(b.interval):
			case <-b.halt:
				return
			}
		}
	}()
	return
}
1073740
func main() {
	cmd.RootCmd.DisableAutoGenTag = true
	identity := func(s string) string {
		return fmt.Sprintf(`{{< relref "docs/%s" >}}`, s)
	}
	emptyStr := func(s string) string { return "" }
	doc.GenMarkdownTreeCustom(cmd.RootCmd, "./", emptyStr, identity)
}
1208758
func (e *SyncedEnforcer) StartAutoLoadPolicy(d time.Duration) {
	e.autoLoad = true
	go func() {
		n := 1
		log.Print("Start automatically load policy")
		for {
			if !e.autoLoad {
				log.Print("Stop automatically load policy")
				break
			}

			// error intentionally ignored
			e.LoadPolicy()
			// Uncomment this line to see when the policy is loaded.
			// log.Print("Load policy for time: ", n)
			n++
			time.Sleep(d)
		}
	}()
}
693773
func (as *Step) Start(startTime *timestamp.Timestamp) bool {
	if as.Started != nil {
		return false
	}
	as.Started = startTime
	return true
}
564098
func (*WindowsStrategy) autostart(c context.Context, path, user string) error {
	subs := map[string]string{
		"BotCode": path,
		"User":    user,
	}
	s, err := substitute(c, string(GetAsset(startupTmpl)), subs)
	if err != nil {
		return errors.Annotate(err, "failed to prepare template %q", startupTmpl).Err()
	}
	p, err := substitute(c, startupCfg, subs)
	if err != nil {
		return errors.Annotate(err, "failed to prepare path: %s", startupCfg).Err()
	}

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

	logging.Infof(c, "starting %q", startupTask)
	cmd := exec.Command(p)
	setFlags(cmd)
	if err := cmd.Start(); err != nil {
		return errors.Annotate(err, "failed to start task %q", startupTask).Err()
	}
	return nil
}
39523
func (bot *TgBot) Start() {
	if bot.ID == 0 {
		fmt.Println("No ID, maybe the token is bad.")
		return
	}

	if bot.MainListener == nil {
		fmt.Println("No listener!")
		return
	}

	removedhook := false

	for {
		updatesList, err := bot.GetUpdates()
		if err != nil {
			fmt.Println(err)
			if !removedhook {
				fmt.Println("Removing webhook...")
				bot.SetWebhook("")
				removedhook = true
			}
			continue
		}
		bot.ProcessMessages(updatesList)
	}
}
391429
func (m *nativeGitClient) Init() error {
	_, err := git.PlainOpen(m.root)
	if err == nil {
		return nil
	}
	if err != git.ErrRepositoryNotExists {
		return err
	}
	log.Infof("Initializing %s to %s", m.repoURL, m.root)
	_, err = exec.Command("rm", "-rf", m.root).Output()
	if err != nil {
		return fmt.Errorf("unable to clean repo at %s: %v", m.root, err)
	}
	err = os.MkdirAll(m.root, 0755)
	if err != nil {
		return err
	}
	repo, err := git.PlainInit(m.root, false)
	if err != nil {
		return err
	}
	_, err = repo.CreateRemote(&config.RemoteConfig{
		Name: git.DefaultRemoteName,
		URLs: []string{m.repoURL},
	})
	return err
}
1312229
func (a *AIP1640Driver) Start() (err error) {
	a.pinData.On()
	a.pinClock.On()

	return
}
509372
func (s *Struct) StartFunc(startProcedure func() error) error {
	s.Lock()
	defer s.Unlock()

	// already started
	if s.exit != nil {
		return nil
	}

	exit := make(chan struct{})
	s.exit = exit
	s.Go = func(callable func(exit chan struct{})) {
		s.wg.Add(1)
		go func() {
			callable(exit)
			s.wg.Done()
		}()
	}
	s.WithExit = func(callable func(exit chan struct{})) {
		callable(exit)
	}

	err := startProcedure()

	// stop all if start failed
	if err != nil {
		s.doStop(func() {})
	}

	return err
}
932736
func Shutdown(c context.Context) {
	state := GetState(c)
	if store.IsNilStore(state.Store()) {
		return
	}

	if state.flusher != nil {
		logging.Debugf(c, "Stopping tsmon auto flush")
		state.flusher.stop()
		state.flusher = nil
	}

	// Flush logs errors inside.
	Flush(c)

	// Reset the state as if 'InitializeFromFlags' was never called.
	Initialize(c, monitor.NewNilMonitor(), store.NewNilStore())
}
763685
func (session *SafeSession) SetAutocommitable(flag bool) {
	session.mu.Lock()
	defer session.mu.Unlock()

	if session.autocommitState == autocommitted {
		panic("BUG: SetAutocommitable: unexpected autocommit state")
	}

	if flag {
		session.autocommitState = autocommittable
	} else {
		session.autocommitState = notAutocommittable
	}
}
720
func (s *scheduler) Start() error {
	if s.metricManager == nil {
		schedulerLogger.WithFields(log.Fields{
			"_block": "start-scheduler",
			"_error": ErrMetricManagerNotSet.Error(),
		}).Error("error on scheduler start")
		return ErrMetricManagerNotSet
	}
	s.state = schedulerStarted
	schedulerLogger.WithFields(log.Fields{
		"_block": "start-scheduler",
	}).Info("scheduler started")

	//Autodiscover
	autoDiscoverPaths := s.metricManager.GetAutodiscoverPaths()
	if autoDiscoverPaths != nil && len(autoDiscoverPaths) != 0 {
		schedulerLogger.WithFields(log.Fields{
			"_block": "start-scheduler",
		}).Info("auto discover path is enabled")
		for _, pa := range autoDiscoverPaths {
			fullPath, err := filepath.Abs(pa)
			if err != nil {
				schedulerLogger.WithFields(log.Fields{
					"_block":           "start-scheduler",
					"autodiscoverpath": pa,
				}).Fatal(err)
			}
			schedulerLogger.WithFields(log.Fields{
				"_block": "start-scheduler",
			}).Info("autoloading tasks from: ", fullPath)
			files, err := ioutil.ReadDir(fullPath)
			if err != nil {
				schedulerLogger.WithFields(log.Fields{
					"_block":           "start-scheduler",
					"autodiscoverpath": pa,
				}).Fatal(err)
			}
			var taskFiles []os.FileInfo
			for _, file := range files {
				if file.IsDir() {
					schedulerLogger.WithFields(log.Fields{
						"_block":           "start-scheduler",
						"autodiscoverpath": pa,
					}).Warning("Ignoring subdirectory: ", file.Name())
					continue
				}
				// tasks files (JSON and YAML)
				fname := strings.ToLower(file.Name())
				if !strings.HasSuffix(fname, ".json") && !strings.HasSuffix(fname, ".yaml") && !strings.HasSuffix(fname, ".yml") {
					continue
				}
				taskFiles = append(taskFiles, file)
			}
			autoDiscoverTasks(taskFiles, fullPath, s.CreateTask)
		}
	} else {
		schedulerLogger.WithFields(log.Fields{
			"_block": "start-scheduler",
		}).Info("auto discover path is disabled")
	}

	return nil
}
6701
func (m *systemdUnitManager) TriggerStart(name string) error {
	jobID, err := m.systemd.StartUnit(name, "replace", nil)
	if err != nil {
		log.Errorf("Failed to trigger systemd unit %s start: %v", name, err)
		return err
	}
	log.Infof("Triggered systemd unit %s start: job=%d", name, jobID)
	return nil
}
1317662
func (s *BatchServiceStateManager) Start() error {

	s.lock.Lock()
	if s.shutdown != nil {
		select {
		case <-s.shutdown:
		default:
			s.lock.Unlock()
			return ErrAlreadyStarted
		}
	}

	s.shutdown = make(chan struct{})
	s.lock.Unlock()

	tenantIDs, err := s.Facade.GetTenantIDs(s.ctx)
	if err != nil {
		return err
	}

	for _, tenantID := range tenantIDs {
		s.AddTenant(tenantID)
	}

	plog.WithFields(logrus.Fields{
		"tenantids": tenantIDs,
	}).Info("Started ServiceStateManager")
	return nil
}
656627
func start() error {
	if *flagSign != "" {
		return signToken()
	} else if *flagVerify != "" {
		return verifyToken()
	} else if *flagShow != "" {
		return showToken()
	} else {
		flag.Usage()
		return fmt.Errorf("None of the required flags are present.  What do you want me to do?")
	}
}
315743
func (r *Repository) GetAutoInit() bool {
	if r == nil || r.AutoInit == nil {
		return false
	}
	return *r.AutoInit
}