make proxy optional

This commit is contained in:
Abhishek Kondur
2022-11-20 09:35:29 +05:30
parent c54080e150
commit f95306ddbd
19 changed files with 294 additions and 167 deletions

33
main.go
View File

@@ -172,24 +172,29 @@ func startControllers() {
if !servercfg.IsAgentBackend() && !servercfg.IsRestBackend() && !servercfg.IsMessageQueueBackend() {
logger.Log(0, "No Server Mode selected, so nothing is being served! Set Agent mode (AGENT_BACKEND) or Rest mode (REST_BACKEND) or MessageQueue (MESSAGEQUEUE_BACKEND) to 'true'.")
}
// starts the stun server
waitnetwork.Add(1)
go stunserver.Start(&waitnetwork)
waitnetwork.Add(1)
go func() {
defer waitnetwork.Done()
ctx, cancel := context.WithCancel(context.Background())
if servercfg.IsProxyEnabled() {
waitnetwork.Add(1)
go nmproxy.Start(ctx, logic.ProxyMgmChan, servercfg.GetAPIHost())
err := serverctl.SyncServerNetworkWithProxy()
if err != nil {
logger.Log(0, "failed to sync proxy with server interfaces: ", err.Error())
}
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGTERM, os.Interrupt)
<-quit
cancel()
}()
go func() {
defer waitnetwork.Done()
ctx, cancel := context.WithCancel(context.Background())
waitnetwork.Add(1)
go nmproxy.Start(ctx, logic.ProxyMgmChan, servercfg.GetAPIHost())
err := serverctl.SyncServerNetworkWithProxy()
if err != nil {
logger.Log(0, "failed to sync proxy with server interfaces: ", err.Error())
}
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGTERM, os.Interrupt)
<-quit
cancel()
}()
}
waitnetwork.Wait()
}