summaryrefslogtreecommitdiff
path: root/commands.go
blob: 600af16a889a31a2279c982e34c027c7a5bc5e1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package roadrunner

import (
	"encoding/json"
	"github.com/spiral/goridge"
)

// TerminateCommand must stop underlying process.
type TerminateCommand struct {
	Terminate bool `json:"terminate"`
}

// PidCommand send greeting message between processes in json format.
type PidCommand struct {
	Pid    int `json:"pid"`
	Parent int `json:"parent,omitempty"`
}

// sends control message via relay using JSON encoding
func sendCommand(rl goridge.Relay, command interface{}) error {
	bin, err := json.Marshal(command)
	if err != nil {
		return err
	}

	return rl.Send(bin, goridge.PayloadControl)
}