diff --git a/cmd/argocd-server/commands/argocd_server.go b/cmd/argocd-server/commands/argocd_server.go index d1e9cf05f98d53..af1527256b9fb5 100644 --- a/cmd/argocd-server/commands/argocd_server.go +++ b/cmd/argocd-server/commands/argocd_server.go @@ -247,11 +247,11 @@ func NewCommand() *cobra.Command { stats.RegisterStackDumper() stats.StartStatsTicker(10 * time.Minute) stats.RegisterHeapDumper("memprofile") - argocd := server.NewServer(ctx, argoCDOpts, appsetOpts) - argocd.Init(ctx) - lns, err := argocd.Listen() - errors.CheckError(err) for { + argocd := server.NewServer(ctx, argoCDOpts, appsetOpts) + argocd.Init(ctx) + lns, err := argocd.Listen() + errors.CheckError(err) var closer func() ctx, cancel := context.WithCancel(ctx) if otlpAddress != "" { diff --git a/server/server.go b/server/server.go index 400ad99ad47a37..98a935c56cf84f 100644 --- a/server/server.go +++ b/server/server.go @@ -597,6 +597,7 @@ func (a *ArgoCDServer) Run(ctx context.Context, listeners *Listeners) { a.stopCh = make(chan struct{}) <-a.stopCh + listeners.Close() } func (a *ArgoCDServer) Initialized() bool {