(conn net.Conn)
| 62 | } |
| 63 | |
| 64 | func (c *commandCenter) handleConnection(conn net.Conn) { |
| 65 | re := regexp.MustCompile(`\S+`) |
| 66 | |
| 67 | utils.ScanLines(conn, func(b []byte) bool { |
| 68 | args := re.FindAllString(string(b), -1) |
| 69 | |
| 70 | if len(args) == 0 { |
| 71 | return true |
| 72 | } |
| 73 | |
| 74 | cmd := args[0] |
| 75 | |
| 76 | if len(args) > 1 { |
| 77 | args = args[1:] |
| 78 | } else { |
| 79 | args = []string{} |
| 80 | } |
| 81 | |
| 82 | switch cmd { |
| 83 | case "restart": |
| 84 | c.processRestart(args) |
| 85 | case "stop": |
| 86 | c.processStop(args) |
| 87 | case "quit": |
| 88 | c.processQuit() |
| 89 | case "kill": |
| 90 | c.processKill() |
| 91 | case "get-connection": |
| 92 | c.processGetConnection(args, conn) |
| 93 | case "echo": |
| 94 | c.processEcho(conn) |
| 95 | case "status": |
| 96 | c.processStatus(conn) |
| 97 | } |
| 98 | |
| 99 | return true |
| 100 | }) |
| 101 | } |
| 102 | |
| 103 | func (c *commandCenter) processRestart(args []string) { |
| 104 | for _, p := range c.cmd.processes { |
no test coverage detected