1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2025-03-13 18:08:42 +00:00
ctrl/cmd/main.go

46 lines
1 KiB
Go
Raw Normal View History

2021-02-01 11:13:38 +01:00
package main
import (
"flag"
"log"
2021-02-05 07:25:12 +01:00
"net/http"
2021-02-01 11:13:38 +01:00
"os"
2021-02-05 07:25:12 +01:00
_ "net/http/pprof"
2021-02-01 11:13:38 +01: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")
// modePublisher := flag.Bool("modePublisher", false, "set to true if it should be able to publish")
// modeSubscriber := flag.Bool("modeSubscriber", false, "set to true if it should be able to subscribe")
2021-02-05 07:25:12 +01:00
profilingPort := flag.String("profilingPort", "", "The number of the profiling port")
2021-02-01 11:13:38 +01:00
flag.Parse()
2021-02-05 07:25:12 +01:00
if *profilingPort != "" {
// TODO REMOVE: Added for profiling
go func() {
http.ListenAndServe("localhost:"+*profilingPort, nil)
}()
}
2021-02-01 11:13:38 +01:00
s, err := steward.NewServer(*brokerAddress, *nodeName)
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 11:13:38 +01:00
//if *modeSubscriber {
// go s.RunSubscriber()
//}
2021-02-01 11:13:38 +01:00
select {}
}