Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .yarn/changelogs/service.38497d1d.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!-- version-type: patch -->
# service

<!--
FORMATTING GUIDE:

### Detailed Entry (appears first when merging)

Use h3 (###) and below for detailed entries with paragraphs, code examples, and lists.

### Simple List Items

- Simple changes can be added as list items
- They are collected together at the bottom of each section

TIP: When multiple changelog drafts are merged, heading-based entries
appear before simple list items within each section.
-->

## ✨ Features
<!-- PLACEHOLDER: Describe your shiny new features (feat:) -->

## 🐛 Bug Fixes
<!-- PLACEHOLDER: Describe the nasty little bugs that has been eradicated (fix:) -->

## 📚 Documentation
<!-- PLACEHOLDER: Describe documentation changes (docs:) -->

## ⚡ Performance
- Improved service startup performance with parallel REST API initialization and deferred stale process detection

## ♻️ Refactoring
<!-- PLACEHOLDER: Describe code refactoring (refactor:) -->

## 🧪 Tests
<!-- PLACEHOLDER: Describe test changes (test:) -->

## 📦 Build
<!-- PLACEHOLDER: Describe build system changes (build:) -->

## 👷 CI
<!-- PLACEHOLDER: Describe CI configuration changes (ci:) -->

## ⬆️ Dependencies
<!-- PLACEHOLDER: Describe dependency updates (deps:) -->

## 🔧 Chores
<!-- PLACEHOLDER: Describe other changes (chore:) -->
5 changes: 5 additions & 0 deletions .yarn/versions/38497d1d.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
releases:
service: patch

declined:
- stack-craft
37 changes: 26 additions & 11 deletions service/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,43 @@ import { encryptExistingSecrets } from './utils/encrypt-existing-secrets.js'
const host = getHost()
const port = getPort()

const logStartupError = (scope: string, error: unknown): void => {
getLogger(injector)
.withScope(scope)
.error({
message: `Background startup task failed: ${error instanceof Error ? error.message : String(error)}`,
data: { error },
})
.catch(() => console.error(`Background startup task failed (logger unavailable) [${scope}]`, error))
}

const setupRestApis = async () => {
await setupDataStore(injector)
await setupLogStore(injector)
await setupPatcher(injector)

injector.get(ExternalGitChangeListener).start()

// Stale-state cleanup and secret re-encryption don't gate REST availability — run them
// in the background so HTTP can start accepting requests sooner.
const processManager = injector.get(ProcessManager)
await processManager.reconcileStaleStates()
void processManager.reconcileStaleStates().catch((error) => logStartupError('StaleStateReconciler', error))

await usingAsync(useSystemIdentityContext({ injector }), async (elevated) => {
void usingAsync(useSystemIdentityContext({ injector }), async (elevated) => {
await encryptExistingSecrets(elevated)
})
}).catch((error) => logStartupError('EncryptExistingSecrets', error))

await setupInstallRestApi(injector)
await setupIdentityRestApi(injector)
await setupStacksRestApi(injector)
await setupServicesRestApi(injector)
await setupGitHubReposRestApi(injector)
await setupPrerequisitesRestApi(injector)
await setupTokensRestApi(injector)
await setupSystemRestApi(injector)
// Each module registers its own route group independently, so they can be set up concurrently.
await Promise.all([
setupInstallRestApi(injector),
setupIdentityRestApi(injector),
setupStacksRestApi(injector),
setupServicesRestApi(injector),
setupGitHubReposRestApi(injector),
setupPrerequisitesRestApi(injector),
setupTokensRestApi(injector),
setupSystemRestApi(injector),
])

const wsService = injector.get(WebsocketService)
await wsService.init(injector)
Expand Down
Loading