1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2025-03-31 01:24:31 +00:00

removed printf's, or made them into log's

This commit is contained in:
postmannen 2021-04-16 13:43:58 +02:00
parent fde053a0cb
commit 64a22c84e9
6 changed files with 26 additions and 28 deletions

View file

@ -238,7 +238,7 @@ func (c *Configuration) ReadConfigFile() (Configuration, error) {
return Configuration{}, fmt.Errorf("error: decode toml file %v: %v", fp, err)
}
fmt.Printf("%+v\n", c)
// fmt.Printf("%+v\n", c)
return conf, nil
}

View file

@ -1,15 +1,15 @@
[
{
"directory":"cli_command__result",
"directory":"cli/command/result",
"fileExtension": ".result",
"toNode": "ship1",
"data": ["bash","-c","sleep 5 & tree ./"],
"data": ["bash","-c","sleep 3 & tree ./"],
"method":"REQCliCommand",
"replyMethod":"REQToFileAppend",
"ACKTimeout":5,
"retries":1,
"replyACKTimeout":5,
"replyRetries":1,
"methodTimeout": 3
"methodTimeout": 5
}
]

View file

@ -227,7 +227,7 @@ func (p process) messageDeliverNats(natsConn *nats.Conn, message Message) {
if err != nil {
er := fmt.Errorf("error: nc.SubscribeSync failed: failed to create reply message: %v", err)
// sendErrorLogMessage(p.toRingbufferCh, node(p.node), er)
fmt.Printf("%v, waiting %ds before retrying\n", er, subscribeSyncTimer)
log.Printf("%v, waiting %ds before retrying\n", er, subscribeSyncTimer)
time.Sleep(time.Second * subscribeSyncTimer)
continue
}
@ -237,7 +237,7 @@ func (p process) messageDeliverNats(natsConn *nats.Conn, message Message) {
if err != nil {
er := fmt.Errorf("error: publish failed: %v", err)
// sendErrorLogMessage(p.toRingbufferCh, node(p.node), er)
fmt.Printf("%v, waiting %ds before retrying\n", er, publishTimer)
log.Printf("%v, waiting %ds before retrying\n", er, publishTimer)
time.Sleep(time.Second * publishTimer)
continue
}
@ -257,7 +257,7 @@ func (p process) messageDeliverNats(natsConn *nats.Conn, message Message) {
// did not receive a reply, decide what to do..
retryAttempts++
fmt.Printf("Retry attempts:%v, retries: %v, ACKTimeout: %v\n", retryAttempts, message.Retries, message.ACKTimeout)
log.Printf("Retry attempts:%v, retries: %v, ACKTimeout: %v\n", retryAttempts, message.Retries, message.ACKTimeout)
switch {
case message.Retries == 0:
// 0 indicates unlimited retries

View file

@ -209,7 +209,7 @@ func (r *ringBuffer) processBufferMessages(samValueBucket string, outCh chan sam
// REMOVE: Dump the whole KV store
err := r.printBucketContent(samValueBucket)
if err != nil {
fmt.Printf("* Error: dump of db failed: %v\n", err)
log.Printf("* Error: dump of db failed: %v\n", err)
}
}(v)
@ -245,11 +245,10 @@ func (r *ringBuffer) dumpBucket(bucket string) ([]samDBValue, error) {
return samDBValues[i].ID > samDBValues[j].ID
})
fmt.Println("--------------------------K/V DUMP TO VARIABLE SORTED---------------------------")
for _, v := range samDBValues {
fmt.Printf("%#v\n", v)
log.Printf("info: k/v store: %#v\n", v)
}
fmt.Println("----------------------------------------------------------------------------------")
return nil
})
@ -273,7 +272,7 @@ func (r *ringBuffer) printBucketContent(bucket string) error {
if err != nil {
log.Printf("error: printBucketContent json.Umarshal failed: %v\n", err)
}
fmt.Printf("k: %s, v: %v\n", k, vv)
log.Printf("k: %s, v: %v\n", k, vv)
return nil
})
fmt.Println("--")
@ -314,7 +313,7 @@ func (r *ringBuffer) getIndexValue(indexBucket string) int {
log.Printf("error: getIndexValue: strconv.Atoi : %v\n", err)
}
fmt.Printf("ringBuffer.getIndexValue: got index value = %v\n", index)
// fmt.Printf("ringBuffer.getIndexValue: got index value = %v\n", index)
return index
}

View file

@ -164,7 +164,7 @@ func (s *server) Start() {
func (p *processes) printProcessesMap() {
fmt.Println("--------------------------------------------------------------------------------------------")
fmt.Printf("*** Output of processes map :\n")
log.Printf("*** Output of processes map :\n")
p.mu.Lock()
for _, v := range p.active {
log.Printf("* proc - : %v, id: %v, name: %v, allowed from: %v\n", v.processKind, v.processID, v.subject.name(), v.allowedReceivers)

View file

@ -16,7 +16,7 @@ func (p process) ProcessesStart() {
// Allways start an REQOpCommand subscriber
{
fmt.Printf("Starting REQOpCommand subscriber: %#v\n", p.node)
log.Printf("Starting REQOpCommand subscriber: %#v\n", p.node)
sub := newSubject(REQOpCommand, string(p.node))
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, []node{node(p.configuration.CentralNodeName)}, nil)
go proc.spawnWorker(p.processes, p.natsConn)
@ -87,7 +87,7 @@ type startup struct{}
func (s startup) subREQHttpGet(p process) {
fmt.Printf("Starting Http Get subscriber: %#v\n", p.node)
log.Printf("Starting Http Get subscriber: %#v\n", p.node)
sub := newSubject(REQHttpGet, string(p.node))
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQHttpGet.Values, nil)
// fmt.Printf("*** %#v\n", proc)
@ -96,7 +96,7 @@ func (s startup) subREQHttpGet(p process) {
}
func (s startup) pubREQHello(p process) {
fmt.Printf("Starting Hello Publisher: %#v\n", p.node)
log.Printf("Starting Hello Publisher: %#v\n", p.node)
sub := newSubject(REQHello, p.configuration.CentralNodeName)
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindPublisher, []node{}, nil)
@ -127,7 +127,6 @@ func (s startup) pubREQHello(p process) {
select {
case <-ticker.C:
case <-ctx.Done():
fmt.Printf(" ** DEBUG: got <- ctx.Done\n")
er := fmt.Errorf("info: stopped handleFunc for: %v", proc.subject.name())
sendErrorLogMessage(proc.toRingbufferCh, proc.node, er)
return nil
@ -138,49 +137,49 @@ func (s startup) pubREQHello(p process) {
}
func (s startup) subREQToConsole(p process) {
fmt.Printf("Starting Text To Console subscriber: %#v\n", p.node)
log.Printf("Starting Text To Console subscriber: %#v\n", p.node)
sub := newSubject(REQToConsole, string(p.node))
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQToConsole.Values, nil)
go proc.spawnWorker(p.processes, p.natsConn)
}
func (s startup) subREQnCliCommand(p process) {
fmt.Printf("Starting CLICommand Not Sequential Request subscriber: %#v\n", p.node)
log.Printf("Starting CLICommand Not Sequential Request subscriber: %#v\n", p.node)
sub := newSubject(REQnCliCommand, string(p.node))
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQnCliCommand.Values, nil)
go proc.spawnWorker(p.processes, p.natsConn)
}
func (s startup) subREQCliCommand(p process) {
fmt.Printf("Starting CLICommand Request subscriber: %#v\n", p.node)
log.Printf("Starting CLICommand Request subscriber: %#v\n", p.node)
sub := newSubject(REQCliCommand, string(p.node))
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQCliCommand.Values, nil)
go proc.spawnWorker(p.processes, p.natsConn)
}
func (s startup) subREQPong(p process) {
fmt.Printf("Starting Pong subscriber: %#v\n", p.node)
log.Printf("Starting Pong subscriber: %#v\n", p.node)
sub := newSubject(REQPong, string(p.node))
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQPong.Values, nil)
go proc.spawnWorker(p.processes, p.natsConn)
}
func (s startup) subREQPing(p process) {
fmt.Printf("Starting Ping Request subscriber: %#v\n", p.node)
log.Printf("Starting Ping Request subscriber: %#v\n", p.node)
sub := newSubject(REQPing, string(p.node))
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQPing.Values, nil)
go proc.spawnWorker(p.processes, p.natsConn)
}
func (s startup) subREQErrorLog(p process) {
fmt.Printf("Starting REQErrorLog subscriber: %#v\n", p.node)
log.Printf("Starting REQErrorLog subscriber: %#v\n", p.node)
sub := newSubject(REQErrorLog, "errorCentral")
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQErrorLog.Values, nil)
go proc.spawnWorker(p.processes, p.natsConn)
}
func (s startup) subREQHello(p process) {
fmt.Printf("Starting Hello subscriber: %#v\n", p.node)
log.Printf("Starting Hello subscriber: %#v\n", p.node)
sub := newSubject(REQHello, string(p.node))
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQHello.Values, nil)
proc.procFuncCh = make(chan Message)
@ -228,7 +227,7 @@ func (s startup) subREQHello(p process) {
}
func (s startup) subREQToFile(p process) {
fmt.Printf("Starting text to file subscriber: %#v\n", p.node)
log.Printf("Starting text to file subscriber: %#v\n", p.node)
sub := newSubject(REQToFile, string(p.node))
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQToFile.Values, nil)
// fmt.Printf("*** %#v\n", proc)
@ -236,7 +235,7 @@ func (s startup) subREQToFile(p process) {
}
func (s startup) subREQToFileAppend(p process) {
fmt.Printf("Starting text logging subscriber: %#v\n", p.node)
log.Printf("Starting text logging subscriber: %#v\n", p.node)
sub := newSubject(REQToFileAppend, string(p.node))
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQToFileAppend.Values, nil)
// fmt.Printf("*** %#v\n", proc)
@ -244,7 +243,7 @@ func (s startup) subREQToFileAppend(p process) {
}
func (s startup) subREQTailFile(p process) {
fmt.Printf("Starting tail log files subscriber: %#v\n", p.node)
log.Printf("Starting tail log files subscriber: %#v\n", p.node)
sub := newSubject(REQTailFile, string(p.node))
proc := newProcess(p.natsConn, p.processes, p.toRingbufferCh, p.configuration, sub, p.errorCh, processKindSubscriber, p.configuration.StartSubREQTailFile.Values, nil)
// fmt.Printf("*** %#v\n", proc)