From 899d2e1f096aa78c037349b0bd0a3d86e4c26d4d Mon Sep 17 00:00:00 2001 From: postmannen Date: Thu, 25 Mar 2021 12:33:53 +0100 Subject: [PATCH] renamed inmsg to steward.sock --- README.md | 18 +++++++++--------- etc/config.toml | 4 ++-- getmessagefromfile.go | 4 ++-- ringbuffer.go | 2 +- server.go | 2 +- inmsg.txt => steward.sock | 0 6 files changed, 15 insertions(+), 15 deletions(-) rename inmsg.txt => steward.sock (100%) diff --git a/README.md b/README.md index f751178..a1f586e 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,7 @@ methodTimeout ### How to send a Message -Right now the API for sending a message from one node to another node is by pasting a structured JSON object into a file called `inmsg.txt` living alongside the binary. This file will be watched continously, and when updated the content will be picked up, umarshaled, and if OK it will be sent a message to the node specified in the `toNode` field. +Right now the API for sending a message from one node to another node is by pasting a structured JSON object into a file called `steward.sock` living alongside the binary. This file will be watched continously, and when updated the content will be picked up, umarshaled, and if OK it will be sent a message to the node specified in the `toNode` field. The `method` is what defines what the event will do. The preconfigured methods are: @@ -213,7 +213,7 @@ NB: Both the keys and the values used are case sensitive. #### Sending a command from one Node to Another Node -Example JSON for appending a message of type command into the `inmsg.txt` file +Example JSON for appending a message of type command into the `steward.sock` file ```json [ @@ -267,11 +267,11 @@ To send a message with custom timeout and amount of retries ] ``` -You can save the content to myfile.JSON and append it to `inmsg.txt` +You can save the content to myfile.JSON and append it to `steward.sock` -`cat myfile.json >> inmsg.txt` +`cat myfile.json >> steward.sock` -The content of `inmsg.txt` will be erased as messages a processed. +The content of `steward.sock` will be erased as messages a processed. #### Sending a message of type Event @@ -286,11 +286,11 @@ The content of `inmsg.txt` will be erased as messages a processed. ] ``` -You can save the content to myfile.JSON and append it to `inmsg.txt` +You can save the content to myfile.JSON and append it to `steward.sock` -`cat myfile.json >> inmsg.txt` +`cat myfile.json >> steward.sock` -The content of `inmsg.txt` will be erased as messages a processed. +The content of `steward.sock` will be erased as messages a processed. ## Concepts/Ideas @@ -319,7 +319,7 @@ and for a shell command of type command to a host named "ship2" ## TODO -- FIX so it can handle multiple slices of input for inmsg.txt +- FIX so it can handle multiple slices of input for steward.sock - Make a scraper that first send an EventACK, and the content of the scraping is returned by a node as a new EventACK back the where the initial event originated. diff --git a/etc/config.toml b/etc/config.toml index f3a8ca2..8bb14fc 100644 --- a/etc/config.toml +++ b/etc/config.toml @@ -11,5 +11,5 @@ StartSayHelloSubscriber = false SubscribersDataFolder = "./data" [StartCentralErrorLogger] - OK = false - Values = [] + OK = true + Values = ["*"] diff --git a/getmessagefromfile.go b/getmessagefromfile.go index 374157a..37f98d5 100644 --- a/getmessagefromfile.go +++ b/getmessagefromfile.go @@ -122,7 +122,7 @@ func newSAM(m Message) (subjectAndMessage, error) { // A []byte will be returned with the content read. func readTruncateMessageFile(fileName string) ([]byte, error) { - f, err := os.OpenFile(fileName, os.O_APPEND|os.O_RDWR, os.ModeAppend) + f, err := os.OpenFile(fileName, os.O_APPEND|os.O_RDWR|os.O_CREATE, os.ModeAppend) if err != nil { log.Printf("error: readTruncateMessageFile: Failed to open file: %v\n", err) return nil, err @@ -169,7 +169,7 @@ func fileWatcherStart(directoryToCheck string, fileUpdated chan bool) { select { case event := <-watcher.Events: if event.Op&fsnotify.Write == fsnotify.Write { - // log.Println("info: inmsg.txt file updated, processing input: ", event.Name) + // log.Println("info: steward.sock file updated, processing input: ", event.Name) //testing with an update chan to get updates fileUpdated <- true } diff --git a/ringbuffer.go b/ringbuffer.go index 707fb8c..a4a8355 100644 --- a/ringbuffer.go +++ b/ringbuffer.go @@ -110,7 +110,7 @@ func (r *ringBuffer) fillBuffer(inCh chan subjectAndMessage, samValueBucket stri } // Check for incomming messages. These are typically comming from - // the go routine who reads inmsg.txt. + // the go routine who reads steward.sock. for v := range inCh { // Check if the command or event exists in commandOrEvent.go diff --git a/server.go b/server.go index 9af48cb..491132b 100644 --- a/server.go +++ b/server.go @@ -117,7 +117,7 @@ func (s *server) Start() { go s.startMetrics() // Start the checking the input file for new messages from operator. - go s.getMessagesFromFile("./", "inmsg.txt", s.newMessagesCh) + go s.getMessagesFromFile("./", "steward.sock", s.newMessagesCh) // // if enabled, start the sayHello I'm here service at the given interval // // REMOVED: diff --git a/inmsg.txt b/steward.sock similarity index 100% rename from inmsg.txt rename to steward.sock