Adding IPC Actions
When adding a new daemon IPC action, three files need to be updated.
Step 1: Define the Action (protocol.go)
Add a constant and payload type to internal/daemon/protocol.go:
const ActionMyAction = "myaction"
type MyActionPayload struct {
Target string `json:"target"`
Custom string `json:"custom,omitempty"`
}
Step 2: Add the Handler (server.go)
Add a case to the action switch in internal/daemon/server.go:
case ActionMyAction:
var payload MyActionPayload
if err := json.Unmarshal(req.Payload, &payload); err != nil {
return Response{Success: false, Error: "invalid payload"}
}
// Implement the action using the supervisor
result, err := s.supervisor.MyAction(payload.Target, payload.Custom)
if err != nil {
return Response{Success: false, Error: err.Error()}
}
data, _ := json.Marshal(result)
return Response{Success: true, Data: data}
Step 3: Use from CLI (cmd/runix/*.go)
The CLI uses sendIPC() generically — no client.go changes needed:
resp, err := sendIPC(daemon.ActionMyAction, daemon.MyActionPayload{
Target: target,
Custom: "value",
})
if err != nil {
// Handle IPC failure
} else if !resp.Success {
return fmt.Errorf("daemon error: %s", resp.Error)
}
// Use resp.Data
Existing Actions Reference
| Action | Payload | Handler |
|---|---|---|
start | StartPayload | Creates and starts a process |
stop | StopPayload | Stops a process |
restart | StopPayload | Restarts a process |
reload | StopPayload | Reloads a process |
delete | StopPayload | Stops and removes a process |
list | nil | Lists all processes |
status | StopPayload | Gets process status |
logs | LogsPayload | Gets process logs |
inspect | StopPayload | Gets detailed process info |
save | nil | Saves process state |
resurrect | nil | Restores saved processes |
rolling_reload | RollingReloadPayload | Rolling reload |
cron_list | nil | Lists cron jobs |
cron_start | CronPayload | Enables a cron job |
cron_stop | CronPayload | Disables a cron job |
cron_run | CronPayload | Triggers a cron job |
config_reload | nil | Reloads configuration |
alive | nil | Health check ping |
Conventions
- All actions are
POST /with JSON body - Payload structs use
jsontags - Responses always have
Success,Data, andErrorfields - Handlers should validate payloads before processing
- Use the supervisor as the single source of truth
What's Next
- Daemon Architecture — Full IPC protocol details
- Adding Commands — CLI-side implementation