fix: defer background services to gateway_start hook #72
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- This is an auto-generated comment: rate limited by coderabbit.ai -->
[!WARNING]
## Rate limit exceeded
> @xDarkicex has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 37 seconds before requesting another review.> To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.
> <details>
<summary>⌛ How to resolve this issue?</summary>
> After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.> We recommend that you space out your commits to avoid hitting the rate limit.
> </details>
>
<details>
<summary>🚦 How do rate limits work?</summary>
> CodeRabbit enforces hourly rate limits for each developer per organization.
> Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
> Please see our FAQ for further information.
> </details>
> <details>
<summary>ℹ️ Review info</summary>
> <details>
<summary>⚙️ Run configuration</summary>
> Configuration used: defaults
> Review profile: CHILL
> Plan: Pro
> Run ID: 56bc518e-8d2a-4fd6-a37a-353692a565f7> </details>
> <details>
<summary>📥 Commits</summary>
> Reviewing files that changed from the base of the PR and between eb1e0fcebbb4241c99745c42722017257b37e328 and f957a2da305ba0368ace18af824fb52e4f34a3cd.
> </details>
> <details>
<summary>📒 Files selected for processing (1)</summary>
> * src/index.ts> </details>
> </details>
<!-- end of auto-generated comment: rate limited by coderabbit.ai -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary>✨ Finishing Touches</summary>
<details>
<summary>🧪 Generate unit tests (beta)</summary>
fix/defer-services-to-gateway-start</details>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->
---
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
<details>
<summary>❤️ Share</summary>
</details>
<!-- review_rate_limit_status_start -->
<sub>Review rate limit: 0/1 reviews remaining, refill in 7 minutes and 37 seconds.</sub>
<!-- review_rate_limit_status_end -->
<sub>Comment @coderabbitai help to get the list of available commands and usage tips.</sub>
<!-- tips_end -->
Heads up: this, #73, and #75 all modify adjacent regions of src/index.ts. If this merges after #73 or #75 (or vice versa), there will be merge conflicts in the api.on(...) registration block. Recommend merging this first and rebasing the others.
Also worth noting: switching from void fire-and-forget to await inside gateway_start is correct — it means startup errors in markdownIngestion.start() or dreamPromotion.start() will now propagate instead of being silently swallowed. That's an improvement, but it could change observable behavior if either service was previously failing silently on some installs.
Required: this PR is based on the pre-registerService startup code. Current main already starts/stops markdown ingestion and dream promotion through api.registerService with named services and non-fatal startup handling. Reintroducing a gateway_start hook here conflicts with that path and would lose the service-registry semantics once rebased. Please rebase onto main and either close this as superseded or adapt the current registerService implementation instead.
Requested changes: this branch is stale against main and the lifecycle change is now superseded by the service registry path.
fixed in PR #75 closed
fuller-stack-dev
xDarkicex
Summary
start()calls from fire-and-forget duringregister()into agateway_starthookgateway_stophook already handles graceful shutdown of both servicesTest plan
npx tsc --noEmitpasses with zero errorsgateway_stophook still callsruntime.shutdown()which drainsonShutdowntasks (markdown/dream stop)