mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 08:47:35 +08:00
make proxy optional
This commit is contained in:
33
main.go
33
main.go
@@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user