mirror of
https://github.com/postmannen/ctrl.git
synced 2025-03-05 14:56:49 +00:00
CLI to Cli
This commit is contained in:
parent
3fbc333b81
commit
4a7f1fff43
5 changed files with 14 additions and 14 deletions
|
@ -108,7 +108,7 @@ type Configuration struct {
|
||||||
// Subscriber for Echo Reply
|
// Subscriber for Echo Reply
|
||||||
StartSubEchoReply flagNodeSlice
|
StartSubEchoReply flagNodeSlice
|
||||||
// Subscriber for CLICommandRequest
|
// Subscriber for CLICommandRequest
|
||||||
StartSubREQCLICommand flagNodeSlice
|
StartSubREQCliCommand flagNodeSlice
|
||||||
// Subscriber for CLICommandRequestNOSEQ
|
// Subscriber for CLICommandRequestNOSEQ
|
||||||
StartSubCLICommandRequestNOSEQ flagNodeSlice
|
StartSubCLICommandRequestNOSEQ flagNodeSlice
|
||||||
// Subscriber for CLICommandReply
|
// Subscriber for CLICommandReply
|
||||||
|
@ -137,7 +137,7 @@ func newConfigurationDefaults() Configuration {
|
||||||
StartSubTextLogging: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubTextLogging: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
StartSubEchoRequest: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubEchoRequest: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
StartSubEchoReply: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubEchoReply: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
StartSubREQCLICommand: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubREQCliCommand: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
StartSubCLICommandRequestNOSEQ: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubCLICommandRequestNOSEQ: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
StartSubCLICommandReply: flagNodeSlice{OK: true, Values: []node{"*"}},
|
StartSubCLICommandReply: flagNodeSlice{OK: true, Values: []node{"*"}},
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ func (c *Configuration) CheckFlags() error {
|
||||||
flag.Var(&c.StartSubTextLogging, "startSubTextLogging", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubTextLogging, "startSubTextLogging", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubEchoRequest, "startSubEchoRequest", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubEchoRequest, "startSubEchoRequest", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubEchoReply, "startSubEchoReply", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubEchoReply, "startSubEchoReply", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubREQCLICommand, "startSubREQCLICommand", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubREQCliCommand, "startSubREQCliCommand", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubCLICommandRequestNOSEQ, "startSubCLICommandRequestNOSEQ", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubCLICommandRequestNOSEQ, "startSubCLICommandRequestNOSEQ", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
flag.Var(&c.StartSubCLICommandReply, "startSubCLICommandReply", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
flag.Var(&c.StartSubCLICommandReply, "startSubCLICommandReply", "Specify comma separated list for nodes to allow messages from. Use \"*\" for from all. Value RST will turn off subscriber.")
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ SubscribersDataFolder = "./data"
|
||||||
OK = true
|
OK = true
|
||||||
Values = ["*"]
|
Values = ["*"]
|
||||||
|
|
||||||
[StartSubREQCLICommand]
|
[StartSubREQCliCommand]
|
||||||
OK = true
|
OK = true
|
||||||
Values = ["*"]
|
Values = ["*"]
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"label":"cli-command-executed-result",
|
"label":"cli-command-executed-result",
|
||||||
"toNode": "ship1",
|
"toNode": "ship1",
|
||||||
"data": ["bash","-c","sleep 3 & tree ./"],
|
"data": ["bash","-c","sleep 3 & tree ./"],
|
||||||
"method":"REQCLICommand",
|
"method":"REQCliCommand",
|
||||||
"timeout":10,
|
"timeout":10,
|
||||||
"retries":3,
|
"retries":3,
|
||||||
"methodTimeout": 4
|
"methodTimeout": 4
|
||||||
|
|
|
@ -95,12 +95,12 @@ func (s *server) ProcessesStart() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start a subscriber for REQCLICommand messages
|
// Start a subscriber for REQCliCommand messages
|
||||||
if s.configuration.StartSubREQCLICommand.OK {
|
if s.configuration.StartSubREQCliCommand.OK {
|
||||||
{
|
{
|
||||||
fmt.Printf("Starting CLICommand Request subscriber: %#v\n", s.nodeName)
|
fmt.Printf("Starting CLICommand Request subscriber: %#v\n", s.nodeName)
|
||||||
sub := newSubject(REQCLICommand, s.nodeName)
|
sub := newSubject(REQCliCommand, s.nodeName)
|
||||||
proc := newProcess(s.processes, s.toRingbufferCh, s.configuration, sub, s.errorKernel.errorCh, processKindSubscriber, s.configuration.StartSubREQCLICommand.Values, nil)
|
proc := newProcess(s.processes, s.toRingbufferCh, s.configuration, sub, s.errorKernel.errorCh, processKindSubscriber, s.configuration.StartSubREQCliCommand.Values, nil)
|
||||||
go proc.spawnWorker(s)
|
go proc.spawnWorker(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ const (
|
||||||
// as a new message.
|
// as a new message.
|
||||||
// The data field is a slice of strings where the first string
|
// The data field is a slice of strings where the first string
|
||||||
// value should be the command, and the following the arguments.
|
// value should be the command, and the following the arguments.
|
||||||
REQCLICommand Method = "REQCLICommand"
|
REQCliCommand Method = "REQCliCommand"
|
||||||
// Execute a CLI command in for example bash or cmd.
|
// Execute a CLI command in for example bash or cmd.
|
||||||
// This is an event type, where a message will be sent to a
|
// This is an event type, where a message will be sent to a
|
||||||
// node with the command to execute and an ACK will be replied
|
// node with the command to execute and an ACK will be replied
|
||||||
|
@ -116,7 +116,7 @@ func (m Method) GetMethodsAvailable() MethodsAvailable {
|
||||||
REQOpCommand: methodREQOpCommand{
|
REQOpCommand: methodREQOpCommand{
|
||||||
commandOrEvent: CommandACK,
|
commandOrEvent: CommandACK,
|
||||||
},
|
},
|
||||||
REQCLICommand: methodREQCLICommand{
|
REQCliCommand: methodREQCliCommand{
|
||||||
commandOrEvent: CommandACK,
|
commandOrEvent: CommandACK,
|
||||||
},
|
},
|
||||||
CLICommandRequestNOSEQ: methodCLICommandRequestNOSEQ{
|
CLICommandRequestNOSEQ: methodCLICommandRequestNOSEQ{
|
||||||
|
@ -391,18 +391,18 @@ func (m methodEchoReply) handler(proc process, message Message, node string) ([]
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
type methodREQCLICommand struct {
|
type methodREQCliCommand struct {
|
||||||
commandOrEvent CommandOrEvent
|
commandOrEvent CommandOrEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m methodREQCLICommand) getKind() CommandOrEvent {
|
func (m methodREQCliCommand) getKind() CommandOrEvent {
|
||||||
return m.commandOrEvent
|
return m.commandOrEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
// handler to run a CLI command with timeout context. The handler will
|
// handler to run a CLI command with timeout context. The handler will
|
||||||
// return the output of the command run back to the calling publisher
|
// return the output of the command run back to the calling publisher
|
||||||
// as a new message.
|
// as a new message.
|
||||||
func (m methodREQCLICommand) handler(proc process, message Message, node string) ([]byte, error) {
|
func (m methodREQCliCommand) handler(proc process, message Message, node string) ([]byte, error) {
|
||||||
log.Printf("<--- CLICommandREQUEST received from: %v, containing: %v", message.FromNode, message.Data)
|
log.Printf("<--- CLICommandREQUEST received from: %v, containing: %v", message.FromNode, message.Data)
|
||||||
|
|
||||||
// Execute the CLI command in it's own go routine, so we are able
|
// Execute the CLI command in it's own go routine, so we are able
|
||||||
|
|
Loading…
Add table
Reference in a new issue