1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00
ctrl/cmd/main.go

44 lines
1.6 KiB
Go
Raw Normal View History

2021-02-01 10:13:38 +00:00
package main
import (
"flag"
"log"
2021-02-05 06:25:12 +00:00
"net/http"
2021-02-01 10:13:38 +00:00
"os"
2021-02-05 06:25:12 +00:00
_ "net/http/pprof"
2021-02-01 10:13:38 +00:00
"github.com/RaaLabs/steward"
)
func main() {
nodeName := flag.String("node", "0", "some unique string to identify this Edge unit")
brokerAddress := flag.String("brokerAddress", "0", "the address of the message broker")
2021-02-05 06:25:12 +00:00
profilingPort := flag.String("profilingPort", "", "The number of the profiling port")
promHostAndPort := flag.String("promHostAndPort", ":2112", "host and port for prometheus listener, e.g. localhost:2112")
centralErrorLogger := flag.Bool("centralErrorLogger", false, "set to true if this is the node that should receive the error log's from other nodes")
defaultMessageTimeout := flag.Int("defaultMessageTimeout", 10, "default message timeout in seconds. This can be overridden on the message level")
defaultMessageRetries := flag.Int("defaultMessageRetries", 0, "default amount of retries that will be done before a message is thrown away, and out of the system")
publisherServiceSayhello := flag.Int("publisherServiceSayhello", 0, "Make the current node send hello messages to central at given interval in seconds")
2021-02-01 10:13:38 +00:00
flag.Parse()
// Start profiling if profiling port is specified
2021-02-05 06:25:12 +00:00
if *profilingPort != "" {
go func() {
http.ListenAndServe("localhost:"+*profilingPort, nil)
}()
}
s, err := steward.NewServer(*brokerAddress, *nodeName, *promHostAndPort, *centralErrorLogger, *defaultMessageTimeout, *defaultMessageRetries, *publisherServiceSayhello)
2021-02-01 10:13:38 +00:00
if err != nil {
log.Printf("error: failed to connect to broker: %v\n", err)
os.Exit(1)
}
// Start the messaging server
go s.Start()
2021-02-01 10:13:38 +00:00
select {}
}