MCPcopy
hub / github.com/DarthSim/overmind / parseProcfile

Function parseProcfile

start/procfile.go:24–91  ·  view source on GitHub ↗
(procfile string, portBase, portStep int, formation map[string]int, formationPortStep int, stopSignals map[string]syscall.Signal)

Source from the content-addressed store, hash-verified

22type procfile []procfileEntry
23
24func parseProcfile(procfile string, portBase, portStep int, formation map[string]int, formationPortStep int, stopSignals map[string]syscall.Signal) (pf procfile) {
25 f, err := os.Open(procfile)
26 utils.FatalOnErr(err)
27
28 port := portBase
29 names := make(map[string]bool)
30
31 err = utils.ScanLines(f, func(b []byte) bool {
32 if len(b) == 0 {
33 return true
34 }
35
36 params := procfileRe.FindStringSubmatch(string(b))
37 if len(params) != 3 {
38 return true
39 }
40
41 name, cmd := params[1], params[2]
42
43 num := 1
44 if fnum, ok := formation[name]; ok {
45 num = fnum
46 } else if fnum, ok := formation["all"]; ok {
47 num = fnum
48 }
49
50 signal := syscall.SIGINT
51 if s, ok := stopSignals[name]; ok {
52 signal = s
53 }
54
55 for i := 0; i < num; i++ {
56 iname := name
57
58 if num > 1 {
59 iname = fmt.Sprintf("%s#%d", name, i+1)
60 }
61
62 if names[iname] {
63 utils.Fatal("Process names must be unique")
64 }
65 names[iname] = true
66
67 pf = append(
68 pf,
69 procfileEntry{
70 Name: iname,
71 OrigName: name,
72 Command: cmd,
73 Port: port + (i * formationPortStep),
74 StopSignal: signal,
75 },
76 )
77 }
78
79 port += portStep
80
81 return true

Callers 1

newCommandFunction · 0.85

Calls 3

FatalOnErrFunction · 0.92
ScanLinesFunction · 0.92
FatalFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…