@@ -67,6 +67,7 @@ import (
67
67
"go.temporal.io/server/common/headers"
68
68
"go.temporal.io/server/common/log"
69
69
"go.temporal.io/server/common/log/tag"
70
+ "go.temporal.io/server/common/membership"
70
71
"go.temporal.io/server/common/metrics"
71
72
"go.temporal.io/server/common/namespace"
72
73
"go.temporal.io/server/common/payload"
@@ -123,6 +124,7 @@ type (
123
124
archivalMetadata archiver.ArchivalMetadata
124
125
healthServer * health.Server
125
126
overrides * Overrides
127
+ membershipMonitor membership.Monitor
126
128
}
127
129
)
128
130
@@ -147,6 +149,7 @@ func NewWorkflowHandler(
147
149
archivalMetadata archiver.ArchivalMetadata ,
148
150
healthServer * health.Server ,
149
151
timeSource clock.TimeSource ,
152
+ membershipMonitor membership.Monitor ,
150
153
) * WorkflowHandler {
151
154
152
155
handler := & WorkflowHandler {
@@ -187,9 +190,10 @@ func NewWorkflowHandler(
187
190
visibilityMrg .GetIndexName (),
188
191
visibility .AllowListForValidation (visibilityMrg .GetName ()),
189
192
),
190
- archivalMetadata : archivalMetadata ,
191
- healthServer : healthServer ,
192
- overrides : NewOverrides (),
193
+ archivalMetadata : archivalMetadata ,
194
+ healthServer : healthServer ,
195
+ overrides : NewOverrides (),
196
+ membershipMonitor : membershipMonitor ,
193
197
}
194
198
195
199
return handler
@@ -202,7 +206,13 @@ func (wh *WorkflowHandler) Start() {
202
206
common .DaemonStatusInitialized ,
203
207
common .DaemonStatusStarted ,
204
208
) {
205
- wh .healthServer .SetServingStatus (WorkflowServiceName , healthpb .HealthCheckResponse_SERVING )
209
+ // Start in NOT_SERVING state and switch to SERVING after membership is ready
210
+ wh .healthServer .SetServingStatus (WorkflowServiceName , healthpb .HealthCheckResponse_NOT_SERVING )
211
+ go func () {
212
+ _ = wh .membershipMonitor .WaitUntilInitialized (context .Background ())
213
+ wh .healthServer .SetServingStatus (WorkflowServiceName , healthpb .HealthCheckResponse_SERVING )
214
+ wh .logger .Info ("Frontend is now healthy" )
215
+ }()
206
216
}
207
217
}
208
218
0 commit comments