| 104 | } |
| 105 | |
| 106 | func (h *Handler) parseFormation(formation string) error { |
| 107 | if len(formation) > 0 { |
| 108 | maxProcNum := h.PortStep / h.FormationPortStep |
| 109 | |
| 110 | entries := strings.Split(formation, ",") |
| 111 | |
| 112 | h.Formation = make(map[string]int) |
| 113 | |
| 114 | for _, entry := range entries { |
| 115 | pair := strings.Split(entry, "=") |
| 116 | |
| 117 | if len(pair) != 2 { |
| 118 | return errors.New("Invalid formation format") |
| 119 | } |
| 120 | |
| 121 | name := strings.TrimSpace(pair[0]) |
| 122 | if len(name) == 0 { |
| 123 | return errors.New("Invalid formation format") |
| 124 | } |
| 125 | |
| 126 | num, err := strconv.Atoi(strings.TrimSpace(pair[1])) |
| 127 | if err != nil || num < 0 { |
| 128 | return fmt.Errorf("Invalid number of processes: %s", pair[1]) |
| 129 | } |
| 130 | if num > maxProcNum { |
| 131 | return fmt.Errorf("You can spawn only %d instances of the same process with port step of %d and formation port step of %d", maxProcNum, h.PortStep, h.FormationPortStep) |
| 132 | } |
| 133 | |
| 134 | h.Formation[name] = num |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | return nil |
| 139 | } |
| 140 | |
| 141 | func (h *Handler) parseStopSignals(signals string) error { |
| 142 | if len(signals) > 0 { |