// AddProcesses extends the services that we launch at boot
495368
func (kern *Kernel) AddProcesses(pl ...process.Launcher) {
	kern.Launchers = append(kern.Launchers, pl...)
}
128764
func (rt *ResourceType) postProcess(name string, traitsMap map[string]Trait, apiDef *APIDefinition) {
	rt.Name = name
	rt.setMethods(traitsMap, apiDef)
	rt.setOptionalMethods()

	// TODO : inherit from other resource type

	// TODO : apply traits
}
1164197
func populateProcessEnvironment(env []string) error {
	for _, pair := range env {
		p := strings.SplitN(pair, "=", 2)
		if len(p) < 2 {
			return fmt.Errorf("invalid environment '%v'", pair)
		}
		if err := os.Setenv(p[0], p[1]); err != nil {
			return err
		}
	}
	return nil
}
104950
func NewProcess() *Process {
	return &Process{
		BinPath: DefaultBinPath,
		Port:    DefaultPort,
		Stdout:  os.Stdout,
		Stderr:  os.Stderr,
	}
}
153396
func (cfg *cloudConfig) AddBootCmd(args ...string) {
	cfg.attrs["bootcmd"] = append(cfg.BootCmds(), strings.Join(args, " "))
}
270757
func AddServiceFlags(flags *pflag.FlagSet) {
	flags.String("name", "", "service name")
	flags.StringSlice("label", nil, "service label (key=value)")

	flags.Uint64("replicas", 1, "number of replicas for the service (only works in replicated service mode)")
	flags.Uint64("replicas-max-per-node", 0, "maximum number of replicas for per node (only works in replicated service mode) (default 0 = unlimited)")

	flags.String("image", "", "container image")
	flags.String("hostname", "", "container hostname")
	flags.StringSlice("command", nil, "override entrypoint")
	flags.StringSlice("args", nil, "container args")
	flags.StringSlice("env", nil, "container env")
	flags.Bool("tty", false, "open a tty on standard streams")
	flags.Bool("open-stdin", false, "open standard input")

	flags.StringSlice("ports", nil, "ports")
	flags.String("network", "", "network name")

	flags.String("memory-reservation", "", "amount of reserved memory (e.g. 512m)")
	flags.String("memory-limit", "", "memory limit (e.g. 512m)")
	flags.String("cpu-reservation", "", "number of CPU cores reserved (e.g. 0.5)")
	flags.String("cpu-limit", "", "CPU cores limit (e.g. 0.5)")
	flags.String("generic-resources", "", "user defined resources request (e.g. gpu=3,fpga=1)")

	flags.Uint64("update-parallelism", 0, "task update parallelism (0 = all at once)")
	flags.String("update-delay", "0s", "delay between task updates (0s = none)")
	flags.String("update-on-failure", "pause", "action on failure during update (pause|continue|rollback)")
	flags.String("update-order", "stop-first", "order of shutting down old task and starting updated task (stop-first|start-first)")

	flags.Uint64("rollback-parallelism", 0, "task update parallelism during rollback (0 = all at once)")
	flags.String("rollback-delay", "0s", "delay between task updates during rollback (0s = none)")
	flags.String("rollback-on-failure", "pause", "action on failure during rollback (pause|continue)")
	flags.String("rollback-order", "stop-first", "order of shutting down old task and starting rolled-back task (stop-first|start-first)")

	flags.String("restart-condition", "any", "condition to restart the task (any, failure, none)")
	flags.String("restart-delay", "5s", "delay between task restarts")
	flags.Uint64("restart-max-attempts", 0, "maximum number of restart attempts (0 = unlimited)")
	flags.String("restart-window", "0s", "time window to evaluate restart attempts (0 = unbound)")

	flags.StringSlice("constraint", nil, "Placement constraint (e.g. node.labels.key==value)")

	// TODO(stevvooe): Replace these with a more interesting mount flag.
	flags.StringSlice("bind", nil, "define a bind mount")
	flags.StringSlice("volume", nil, "define a volume mount")
	flags.StringSlice("tmpfs", nil, "define a tmpfs mount")
	flags.StringSlice("npipe", nil, "define a npipe mount")

	flags.String("log-driver", "", "specify a log driver")
	flags.StringSlice("log-opt", nil, "log driver options, as key value pairs")

	flags.Bool("init", false, "Run an init inside the container that forwards signals and reaps processes")
}
1178411
func (s *ProcessingConfiguration) SetProcessors(v []*Processor) *ProcessingConfiguration {
	s.Processors = v
	return s
}
1105583
func baseProcess(lc fx.Lifecycle) goprocess.Process {
	p := goprocess.WithParent(goprocess.Background())
	lc.Append(fx.Hook{
		OnStop: func(_ context.Context) error {
			return p.Close()
		},
	})
	return p
}
1293602
func (s *ClientConfigChangerSink) AddEvents(ctx context.Context, events []*event.Event) error {
	s.mu.RLock()
	defer s.mu.RUnlock()
	return s.Destination.AddEvents(ctx, events)
}
132299
func loadProcessConfig(path string) (*specs.Process, error) {
	f, err := os.Open(path)
	if err != nil {
		if os.IsNotExist(err) {
			return nil, fmt.Errorf("JSON configuration file for %s not found", path)
		}
		return nil, err
	}
	defer f.Close()
	var s *specs.Process
	if err := json.NewDecoder(f).Decode(&s); err != nil {
		return nil, err
	}
	return s, nil
}
224768
func (g *Generator) AddProcessAdditionalGid(gid uint32) {
	g.initConfigProcess()
	for _, group := range g.Config.Process.User.AdditionalGids {
		if group == gid {
			return
		}
	}
	g.Config.Process.User.AdditionalGids = append(g.Config.Process.User.AdditionalGids, gid)
}
1323892
func (a *Agent) AddService(service *structs.NodeService, chkTypes []*structs.CheckType, persist bool, token string, source configSource) error {
	a.stateLock.Lock()
	defer a.stateLock.Unlock()
	return a.addServiceLocked(service, chkTypes, persist, token, source)
}
364100
func (h *jsonBasedHyperstart) WaitProcess(container, process string) int {
	h.Lock()
	pk := pKey{c: container, p: process}
	if ps, ok := h.procs[pk]; ok {
		if ps.waitChan == nil {
			ps.waitChan = make(chan int, 1)
			h.handleWaitProcess(pk, ps)
		}
		h.Unlock()
		status := <-ps.waitChan
		ps.waitChan <- status
		return status
	}
	h.Unlock()
	return -1
}
1367702
func (b *Sortable) AsSortProcess() *SortProcess {
	return &SortProcess{
		Keys: b.Keys,
		AsSort: func(data []Record) sort.Interface {
			b.Data = data
			return b
		},
	}
}
1143704
func (p *Plugin) NewProcess(name, cmd string, options ...POption) ProcessInstance {
	newPr := &Process{
		log:     p.Log,
		name:    name,
		cmd:     cmd,
		options: &POptions{},
		sh:      &status.Reader{Log: p.Log},
		status: &status.File{
			State: status.Initial,
		},
		cancelChan: make(chan struct{}),
	}
	for _, option := range options {
		option(newPr.options)
	}
	p.processes = append(p.processes, newPr)

	if newPr.options.template {
		p.writeAsTemplate(newPr)
	}

	return newPr
}
1214022
func (c *Gcd) StartProcess(exePath, 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)
	// profile directory
	c.flags = append(c.flags, fmt.Sprintf("--user-data-dir=%s", c.profileDir))
	// debug port to use
	c.flags = append(c.flags, fmt.Sprintf("--remote-debugging-port=%s", port))
	// bypass first run check
	c.flags = append(c.flags, "--no-first-run")
	// bypass default browser check
	c.flags = append(c.flags, "--no-default-browser-check")

	c.chromeCmd = exec.Command(exePath, c.flags...)
	// add custom environment variables.
	c.chromeCmd.Env = os.Environ()
	c.chromeCmd.Env = append(c.chromeCmd.Env, c.env...)

	return c.startProcess()
}
678737
func (p *Procstat) updateProcesses(pids []PID, tags map[string]string, prevInfo map[PID]Process) (map[PID]Process, error) {
	procs := make(map[PID]Process, len(prevInfo))

	for _, pid := range pids {
		info, ok := prevInfo[pid]
		if ok {
			// Assumption: if a process has no name, it probably does not exist
			if name, _ := info.Name(); name == "" {
				continue
			}
			procs[pid] = info
		} else {
			proc, err := p.createProcess(pid)
			if err != nil {
				// No problem; process may have ended after we found it
				continue
			}
			// Assumption: if a process has no name, it probably does not exist
			if name, _ := proc.Name(); name == "" {
				continue
			}
			procs[pid] = proc

			// Add initial tags
			for k, v := range tags {
				proc.Tags()[k] = v
			}

			// Add pid tag if needed
			if p.PidTag {
				proc.Tags()["pid"] = strconv.Itoa(int(pid))
			}
			if p.ProcessName != "" {
				proc.Tags()["process_name"] = p.ProcessName
			}
		}
	}
	return procs, nil
}