Fix Temporal worker startup order#319
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts Temporal initialization so workflows/activities are registered before any Temporal workers are started, preventing startup-order issues.
Changes:
- Added an explicit
StartWorkers()lifecycle step to the Temporal service interface and implementation. - Moved Temporal worker startup to occur after workflow/activity registration (and after provider initialization in server mode).
- Updated Temporal integration test setup to start workers after registration.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/integration/services/temporal_test.go | Starts Temporal workers after registering test workflow/activity. |
| internal/models/temporal.go | Extends Temporal service interface with StartWorkers(). |
| internal/config/temporal.go | Uses servicesClient directly when registering Temporal workflows/activities. |
| internal/config/services/temporal/multi_worker.go | Updates lifecycle comment to reflect new StartWorkers() step. |
| internal/config/services/temporal/main.go | Splits worker creation vs startup; adds worker-start tracking/state. |
| internal/config/services.go | Makes Temporal setup run during service initialization; adds StartTemporalWorkers(). |
| internal/config/providers.go | Ensures services are initialized earlier (server mode) and starts Temporal workers after providers init. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ync.Once race - TemporalClient.started map was only ever written and len()-checked in StartWorkers(), then nilled in Shutdown(). Replace with a local startedCount variable — workers remains the single authoritative map. - SetupTemporal() was called inside GetServices()'s sync.Once, which meant any early non-server caller (e.g. HasAnalytics() from the config.Load() goroutine) would consume the Once and leave Temporal workflows/activities permanently unregistered for the process. Move SetupTemporal() out of the sync.Once and into InitializeProviders(), which is only invoked from explicit server-start paths after SetMode(ModeServer) has already run. Return the error instead of just logging it — a registration failure is fatal for a server process.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #
Type of Change
feat– New feature (minor version bump)fix– Bug fix (patch version bump)refactor– Code refactoring, no functional changedocs– Documentation onlytest– Adding or updating testschore– Build, CI, dependency updatesmajor/BREAKING CHANGE– Breaking change (major version bump)What Changed
Provider / Workflow / Role Changes
config/providers/)config/roles/)config/workflows/)examples/)Security Considerations
Security notes (if applicable):
Testing
go test ./...)Manual test scenario (if applicable):
Breaking Changes
Migration steps (if applicable):
Documentation
docs/updatedREADME.mdupdatedChecklist
mainfeat:,fix:,major:, etc.)